This article introduces you to Mysql installation and configuration tuning, and then mentions various methods for changing the root password of MySQL in the article. Friends who need it can refer to it
1. Installation
apt-get install mysql-server You need to set the account password
##
apt-get isntall mysql-client apt-get libmysqlclient-dev2.sudo netstat -tap | grep mysql to check whether the installation is successful
root@xyz:~# netstat -tap | grep mysql tcp6 0 0 [::]:mysql [::]:* LISTEN 7510/mysqld -->安装成功
2. Set up mysql remote access
1. Edit In the mysql configuration file, annotate bind-address = 127.0.0.1vi /etc/mysql/mysql.conf.d/mysqld.cnf2. Use root to enter the mysql command line and execute the following 2 commands. In the example, mysql Root account password: root
grant all on *.* to root@'%' identified by 'root' with grant option; flush privileges;3. Restart mysql
/etc/init.d/mysql restart
3. MySQL Multiple methods to change the root password
Method 1: Use the SET PASSWORD command
mysql -u root mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
Method 2: Use mysqladmin
##
mysqladmin -u root password "newpass"
mysqladmin -u root password oldpass "newpass"
mysql -u root mysql> use mysql; mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root'; mysql> FLUSH PRIVILEGES; 在丢失root密码的时候,可以这样 mysqld_safe --skip-grant-tables& mysql -u root mysql mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root'; mysql> FLUSH PRIVILEGES;
Summary
The above is the detailed content of Introduction to methods of changing root password and installation and configuration tuning in Mysql. For more information, please follow other related articles on the PHP Chinese website!