Архив рубрики: mysql

Fail to start MySQL

!!!After all for change password and privileges:

mysql_secure_installation

Symptoms

  • MySQL has been upgraded and now fails to start.
  • The following error message appears in /var/log/mysqld.log when trying to start MySQL:

    [ERROR] Fatal error: mysql.user table is damaged. Please run mysql_upgrade.

  • Plesk is not accessible with the following error message in a browser:

    ERROR: Zend_Db_Adapter_Exception: SQLSTATE[HY000] [2002] No such file or directory
    Additionally, an exception has occurred while trying to report this error: Zend_Exception
    No entry is registered for key 'translate' (Abstract.php:144)

Cause

MySQL 5.1 has been upgraded to 5.5 without running the «mysql_upgrade» command.

Resolution

  1. Connect to the Plesk server via SSH.
  2. Add the «skip-grant-tables» record to log in to MySQL:2.1. Open MySQL configuration file /etc/my.cnf in a text editor. In this example we use the vi editor:

    vi /etc/my.cnf

    2.2. Add «skip-grant-tables» on a new line under the [mysqld] section:

    [mysqld]
    skip-grant-tables
    <…>

    2.3. Save the changes and close the file.

  3. Start MySQL:

    service mysqld start

    OR

    service mysql start

  4. Complete the MySQL upgrade:

    mysql_upgrade

  5. Remove the line with «skip-grant-tables» from the /etc/my.cnf file.
  6. Restart MySQL:

    service mysqld restart

    OR

    service mysql start

 

For over ways https://ruhighload.com/mysql+1045+access+denied+for+user

 

mysql privilegies access

link

 

 

Your root account, and this statement applies to any account, may only have been added with localhost access (which is recommended).

You can check this with:

SELECT host FROM mysql.userWHEREUser='root';

If you only see results with localhost and 127.0.0.1, you cannot connect from an external source. If you see other IP addresses, but not the one you’re connecting from — that’s also an indication.

You will need to add the IP address of each system that you want to grant access to, and then grant privileges:

CREATEUSER'root'@'ip_address' IDENTIFIED BY'some_pass';GRANTALL PRIVILEGES ON*.*TO'root'@'ip_address';

If you see %, well then, there’s another problem altogether as that is «any remote source». If however you do want any/all systems to connect via root, use the % wildcard to grant access:

CREATEUSER'root'@'%' IDENTIFIED BY'some_pass';GRANTALL PRIVILEGES ON*.*TO'root'@'%';

Finally, reload the permissions, and you should be able to have remote access:

FLUSH PRIVILEGES;



Following two steps worked perfectly fine for me:

  1. Comment out the bind address from the file /etc/mysql/my.cnf:

    #bind-address = 127.0.0.1

  2. Run following query in phpMyAdmin:

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'; FLUSH PRIVILEGES;





view install mysql in sustem and reinstall

rpm -qa | grep mysql
find / -name mysql-community-libs-5.7.9-1.e17.x86_64
yum install mysql mysql-devel mysql-libs mysql-server php-mysql linode-longview perl-DBD-MySQL php-cli php-fpm php-gd php-imap php-ldap php-magickwand php-mbstring php-mcrypt php-mssql php-odbc php-pdo php-pear php-process php-shout php-snmp php-soap  php-tidy php-xml php-xmlrpc php-common

PS may be problems without  compat-mysql51-5.1.73-1.el6.remi.x86_64

create database

link

I always forget the MySQL create database with UTF8 character set syntax, so here it is:

CREATE DATABASE `mydb` CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANTALLON`mydb`.*TO`username`@localhost IDENTIFIED BY 'password';

Alternatively, you can use ‘CREATE SCHEMA’ instead of ‘CREATE DATABASE’:

CREATESCHEMA`mydb` CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANTALLON`mydb`.*TO`username`@localhost IDENTIFIED BY 'password';

how to fix phpMyAdmin session error

phpMyAdmin is great free web based PHP software to manage databases, tables, fields, users… and more. phpMyAdmin support MySQL, MariaDB, and Drizzle with the ability to execute SQL statements.

Unfortunately sometimes I get problem with phpMyAdmin, here is the error from phpMyAdmin on my centos Linux Server

phpMyAdmin – Error

To test and find out where is session.save path
http://wiki.phpmyadmin.net/pma/session.save_path

run this script on your web server

Here is the output i have

If the folder doesn’t exist, create one.

 

You may have to change ownership of the directly

 

 

Or just need to change the permissions to readable and writable for the directory

 

 

Note: /var/lib/php/session ownership and permissions well reverse back to root and not writable after a reboot. It’s a good idea to run chmod and chown @reboot so you don’t have to do it manually.

add this to your crontab

with the content (replace user:group to user/group which running apache/nginx web server)

mysql workbanch remotly

CREATEUSER'username'@'localhost' IDENTIFIED BY'password';
GRANTALL PRIVILEGES ON*.*TO'username'@'localhost'WITHGRANTOPTION;
CREATEUSER'username'@'%' IDENTIFIED BY'password';
GRANTALL PRIVILEGES ON*.*TO'username'@'%'WITHGRANTOPTION;
FLUSH PRIVILEGES;

mysql utf8

 

CREATE DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER SCHEMA database DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
ALTER TABLE table_name CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE mytable CONVERTTO CHARACTER SET utf8;
show table status;

How to install MySQL Server 5.6 on CentOS 7 / RHEL 7

How to install MySQL Server 5.6 on CentOS 7 / RHEL 7

In this tutorial we will learn, how to install MySQL Server 5.6 on CentOS 7 / RHEL 7 . In our previous post, we have installed MySQL Server 5.6 on CentOS 6.x/RHEL 7.x.

In CentOS 7/ RHEL 7 , now MariaDB is introduced as a defualt database. Still many Organisations/Company would like to continue with MySQL. Whereas System Admin who earlier worked on MySQL can easily work on MariaDB. MariaDB is a community-developed fork of the MySQL relational database management system.

MariaDB’s lead developer is Michael “Monty” Widenius, the founder of MySQL and Monty Program AB. He had previously sold his company, MySQL AB, to Sun Microsystems for US$1 billion. MariaDB is named after Monty’s younger daughter, Maria. (Reference taken from Wikipedia)

Install MySQL Server 5.6 on CentOS 7 / RHEL 7

Follow the given below steps to install MySQL Server 5.6 .
You must be login with root user in system

Download the Yum Repo package of MySQL Server 5.6

Download the rpm package, which will create a yum repo file for MySQL Server installation.

yum install wget
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

Install mysql-community-release-el7-5.noarch.rpm package

Install this downloaded rpm package by using rpm command.

rpm -ivh mysql-community-release-el7-5.noarch.rpm

After the installation of this package. We will get two new yum repo related to MySQL

[root@localhost ~]# ls -1 /etc/yum.repos.d/mysql-community*
/etc/yum.repos.d/mysql-community.repo
/etc/yum.repos.d/mysql-community-source.repo
[root@localhost ~]#

Installing MySQL Server

By using yum command, now we will install MySQL Server 5.6 . All dependencies will be installed itself.

yum install mysql-server

How to start/stop/restart MySQL Server

Now MySQL Server is installed on your system.

To start MySQL Service
, run command

chkconfig mysqld on
systemctl start mysqld

To stop MySQL Service, run command

systemctl stop mysqld

To restart MySQL Service, run command

systemctl restart mysqld

To get status of MySQL Service, run command

systemctl status mysqld

Reset MySQL root password

On fresh installation of MySQL Server. The MySQL root user password is blank.
For good security practice, we should reset the password MySQL root user.

On newly installed MySQL Server, we generally recommend to use the command script. You have to just follow the instructions.

mysql_secure_installation

In another method,you can log into MySQL server database and reset the password in secure way.

mysql -u root

You will see mysql prompt like this mysql> . Use the below given commands to reset root’s password.

mysql> use mysql;
mysql> update user set password=PASSWORD("GIVE-NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit