Detailed steps for installing CentOS under MySQL

  • 2020-05-12 06:43:32
  • OfStack

First, install the mysql server through the network link. (note: when I started logging in to the server, I was using other users instead of super administrators, so when installing MySQL, I needed to switch to super administrators to install the software correctly. The command is: su root, then enter your super administrator password to log in to the super administrator terminal.

Step 1, install MySQL.


[root@localhost centos]# yum install mysql-server

Waiting for terminal prompt: Complete! During the session, the program will ask for a prompt: Is This ok [y/N] : you know this is supposed to be y.

Step 2, let MYSQL start automatically with the system.


[root@localhost centos]# chkconfig  � levels 235 mysqld on
[root@localhost centos]# /etc/init.d/mysqld start

Step 3, set the username and password for MySQL.


[root@localhost centos]#mysql_secure_installation

In this way, as long as you know a little English, you can understand the data information Settings of Mysql.

Then there is the problem of testing the MYSQL installation with the password set. [root @localhost centos]# mysql-u root-p then enter mysql > Command line, add 1 and database management user!

First, switch to the root permissions, edit the configuration MySQL file, and make use of the insert command i and ESC+:wq commands in the vim command.


[root@sample ~]#vim /etc/my.cnf   please   The editor MySQL Configuration file 
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
old_passwords=1   Please find the 1 In this 1 Lines add new rules so that MySQL The default encoding is UTF-8
default-character-set = utf8   please   Add this 1 Lines of code 
[root@ywm /]# chkconfig mysqld on   please  changes the specified service mysqld The startup information of, on and off Specify the start and stop of the service, respectively. 
[root@ywm /]# chkconfig  �  -list mysqld   please  listing system mysqld The startup information if 2 ~ 5 Is the state of startup OK . 
mysqld 0: Shut down  1: Shut down  2: To enable the  3: To enable the  4: To enable the  5: To enable the  6: Shut down 
[root@ywm /]# /etc/rc.d/init.d/mysqld start  Please start the Mysql System services 

Starting mysqld: [ok]

Ok, so the system's MySQL service Settings have started successfully.

Start setting the user password for the database.

1. Enter the database first (mysql-u root is the user name and password of the super administrator. The default password for database installation is empty.) :


[root@ywm /]# mysql -u root
mysql> select Host,User,Password from mysql.user;  ← query existing database user name and password 
+ -- -- � + - + -- - -+
| Host | User | Password |
+ -- -- � + - + -- - -+
| localhost | root | |
| ywm.localdomain | root | |
| 127.0.0.1 | root | |
| localhost | | |
| ywm.localdomain | | |
+ -- -- � + - + -- - -+
 rows in set (0.00 sec)

2. Modify the password of database user name through database programming, super administrator root. You need to change the username and password for two locations: @localhost and @ywm.localdomain (the name of the host installation), and the password needs to be added to the corresponding data table with the password(' new password set ') Settings.


mysql> set password for root@localhost = password( ' sniper');
Query OK, 0 rows affected (0.00 sec)
mysql> set password for root@ywm.localdomain = password( ' sniper');
Query OK, 0 rows affected (0.00 sec)

3. Exit the command of database setting.


mysql> exit
Bye

Check whether the password in the database has been changed correctly.

1, use the default password is empty login database test 1.


[root@ywm /]# mysql -u root
ERROR 1045 (28000): Access denied for user  ' root'@'localhost' (using password: NO)

2. Use the password that has been set and modified to log in the database for 1 test.


[root@ywm /]# mysql -u root -p
Enter password:
mysql>

Successfully logged into the database.


Related articles: