Problems encountered in installing MySQL under Linux

1. The problem that the installation cannot be successful due to the problem of the installation package
Solution: replace the installation package
2. After the installation is successful, start the mysql service
service mysql start (to be checked for versions above mysql 5.5)
service mysqld start (to be checked for versions prior to mysql5.5)
3. After the installation is successful, the mysql password is set to be empty by default, and the mysql command line cannot be entered normally.
Solution:
(1) Find the my.cnf configuration file: command find -name my.cnf
(2) Edit my.cnf and add skip-grant-tables in [mysqld]
Restart the mysql service after saving
[root@localhost etc]# service mysqld restart
Shutting down MySQL.                                       [  OK  ]
Starting MySQL.                                            [ OK   ]
(3) Log in to the database and reset the root password
	Command: mysql -uroot -p mysql
	Enter password: Enter directly
	execute the following statement

mysql> update user set password=password("mysql") where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 

(4) Delete the "skip-grant-tables" line added in the /etc/my.cnf file and restart mysql;
	You can log in normally with the new password;

(5) After re-login, the following problems will occur:
	mysql> show databases;
	ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

	The workaround is as follows:
	mysql>  SET PASSWORD = PASSWORD('123456');
	Query OK, 0 rows affected (0.03 sec)

	mysql> show databases;
	Query OK, 1 row affected (0.00 sec)

	That is, use mysql> SET PASSWORD = PASSWORD('123456'); to reset the password once!

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327060226&siteId=291194637