CentOS MySQL installation detailed steps _linux

Source: Internet
Author: User

First of all through the network link to install online MySQL server side bar! (Note: I started to log on to the server with other users than the Super administrator, so when installing MySQL need to switch to the Super administrator to achieve the correct installation of software.) The command is: Su root, and then enter your super admin password to log in to the Super Administrator terminal. )

The first step is to install MySQL.

[Root@localhost centos]# Yum Install Mysql-server

Static to Terminal tip: complete! During the period the program asks for hints: Is this OK [y/n]: You know this should be to lose Y.

The second step is to have MySQL start automatically with the system.

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

The third step is to set MySQL username and password.

[Root@localhost CentOS] #mysql_secure_installation

So as long as the understanding of a little English knowledge can be read MySQL data information settings.

Then you use the Set password to test the MySQL installation problem. [Root@localhost centos]# mysql-u root-p then enter the mysql> command line, add one and database Admin user!

First switch to root, edit the configuration MySQL file, take advantage of the Insert command I command and ESC+:WQ command in the VIM command.

[Root@sample ~] #vim/etc/my.cnf← edit MySQL configuration file
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/ Mysql.sock
old_passwords=1← found this line to add a new rule in this line, let MySQL default encoding for UTF-8
default-character-set = utf8← Adding this line of code
[ ROOT@YWM/]# chkconfig mysqld on← Change the startup information for the specified service mysqld, on and off to specify the start and stop of the service respectively.
[root@ywm/]# chkconfig–-list mysqld← lists startup information for the system mysqld, OK if the 2~5 status is started.
mysqld 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off
[Root@ywm/]#/etc/rc.d/init.d/mysqld start← start MySQL system service

Starting mysqld: [OK]

Well, the MySQL service setup from this system has started successfully.

The user password for the database is set up below.

1, first into the database (with the Super Administrator username and password mysql-u root, the database installation default password is empty. ):

[Root@ywm/]# mysql-u root
mysql> select Host,user,password from mysql.user;← query existing database username 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, through the database program to modify the database user name password, super Administrator root. Here you need to modify the two-location username password: @localhost and @ywm.localdomain (name of the host installation), the password needs to be added to the corresponding datasheet with the password (' Set new password ') setting.

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 database Settings command.

Mysql> Exit
Bye

Detects if the password in the database has been modified correctly.

1, use the default password for the blank login database test.

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

2, using the password has been set to login database test.

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

Successfully logged in to the database.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.