1. Stop the database server first service mysqld stop 2.vim /etc/my.cnf 3. Add skip-grant-tables to the configuration file [root@VM_0_8_centos ~]# vim /etc/my.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html [mysqld] # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock skip-grant-tables here! ! ! ! ! ! # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 4. Restart the database systemctl restart mysql 5. Log in to the database mysql -uroot -p If asked for a password, log in with an empty password 6.set password for root@localhost = password('123456'); You can change the password in the brackets yourself. 7.mysql -uroot -p123456 login successful PS: Let's take a look at the Mysql initialization root password and allow remote access The default mysql root user has no password. Enter mysql –u root to enter mysql. 1. Initialize the root password Enter the mysql database mysql>update user set password=PASSWORD('123456') where User='root'; 2. To allow remote access to MySQL, you can use the following three methods: a. Modify the table. mysql -u root –p mysql>use mysql; mysql>update user set host = '%' where user = 'root'; mysql>select host, user from user; b. Authorization. For example, you want to connect to the mysql server as root using 123456 from any host. mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; If you want to allow user jack to connect to mysql server from host with ip 10.10.50.127 and use 654321 as password mysql>GRANT ALL PRIVILEGES ON *.* TO 'jack'@'10.10.50.127' IDENTIFIED BY '654321' WITH GRANT OPTION; mysql> FLUSH RIVILEGES c: Run on the machine where mysql is installed: //Enter the MySQL server d:\mysql\bin\>mysql -h localhost -u root //Give any host access to data mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION //Make the changes effectivemysql>FLUSH PRIVILEGES //Exit the MySQL servermysql>EXIT Summarize This is the end of this article about how to initialize the installation password of MySQL6 under CentOS7. For more information about how to initialize the installation password of MySQL6 under CentOS7, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Example of troubleshooting method to solve Nginx port conflict
>>: Native js custom right-click menu
Table of contents Preface optimization SSR Import...
1. What is mycat A completely open source large d...
Table of contents Preface 1. Uninstall MySQL 2. I...
After I installed MySQL, when I tried to save and...
mysql-5.7.20-winx64.zipInstallation package witho...
1. Prepare the Docker environment 2. Search for f...
This article uses examples to describe MySQL tran...
I've been learning about stacking contexts re...
The mini program collected user personal informat...
Table of contents Preface Why do we need to encap...
Preface This control will have a watermark at the...
Preface As we all know, everything in Linux is a ...
Table of contents 1. Nodes, trees, and virtual DO...
Table of contents Initialize the project Writing ...
As the company's influence grows and its prod...