Home > Database > Mysql Tutorial > body text

Introduction to methods of changing root password and installation and configuration tuning in Mysql

黄舟
Release: 2017-07-30 14:21:52
Original
1831 people have browsed it

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-dev
Copy after login

2.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 -->安装成功
Copy after login

2. Set up mysql remote access

1. Edit In the mysql configuration file, annotate bind-address = 127.0.0.1


vi /etc/mysql/mysql.conf.d/mysqld.cnf
Copy after login

2. 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;
Copy after login

3. Restart mysql


/etc/init.d/mysql restart
Copy after login

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');
Copy after login

Method 2: Use mysqladmin

##

  mysqladmin -u root password "newpass"
Copy after login

If root has set a password, use the following method

 mysqladmin -u root password oldpass "newpass"
Copy after login

Method 3: Use UPDATE to directly edit the user table

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;
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template