Reputation: 26896
When I use mysqld_safe to start my MySQL in CentOS7:
[root@localhost bin]# mysqld_safe --skip-grant-tables &
[1] 32586
[root@localhost bin]# 2017-09-07T13:29:36.423040Z mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
2017-09-07T13:29:36.456574Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
It get stuck in the mysqld_safe Starting mysqld daemon
.
I find the SO, do not find this post, and some similar, but is not stuck, they report error directly.
MySQL version is 5.7.19
My requirement is change the user root
's password.
Upvotes: 2
Views: 12730
Reputation: 139
For Ubuntu 18 and MySQL 5.7 configuration
nano /etc/mysql/mysql.conf.d/mysqld.cnf
add skip-grant-tables
under [mysqld]
systemctl restart mysql
mysql
Now you can change the password of root or any
And remove skip-grant-tables
under [mysqld]
after changing the password and again systemctl restart mysql
for normal function.
Upvotes: 0
Reputation: 26896
At last, I find if change the mysql version greater than 5.7's password, we should not use the outdated method.
The correct method:
In the mysql config file /etc/my.cnf
, add skip-grant-tables
in the [mysqld]
.
Restart mysql (/etc/init.d/mysqld restart
)
Start mysql (type mysql directly
)
Change the password of user(root
)
ALTER USER 'root'@'localhost'IDENTIFIED BY 'newpassword'
Exit mysql and delete the skip-grant-tables
in /etc/my.cnf
Then you can use mysql -u root -p
to login the mysql now.
Upvotes: 9
Reputation: 11270
To change the root's password, you can run mysql_secure_installation
https://mariadb.com/kb/en/library/mysql_secure_installation/
Upvotes: 1