Install MySQL in CentOS and MySQL in CentOS

Source: Internet
Author: User

Install MySQL in CentOS and MySQL in CentOS

First, install the mysql server online through the network link! (Note: When I log on to the server, I use another user instead of a super administrator. Therefore, when installing MySQL, I need to switch to the super administrator to install the software correctly. The command is: su root, and then enter your super administrator password to log on to the super administrator terminal .)

Step 1: Install MySQL.

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

Wait terminal prompt: Complete! During This period, the program will ask: Is This OK [y/N]: You know This should be y.

Step 2: Enable MYSQL to automatically start with the system.

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

Step 3: Set the MySQL user name and password.

[Root @ localhost centos] # mysql_secure_installation

In this way, you only need to understand a little bit of English knowledge and can understand the Mysql DATA settings.

Then the problem of MYSQL installation is tested with the set password. [Root @ localhost centos] # mysql-u root-p and press enter to enter mysql> command line. Add a database management user!

Switch to the root permission, edit and configure the MySQL file, and use the INSERT command I and ESC +: wq commands in the vim command.
[Root @ sample ~] # Vim/etc/my. cnf plugin edit the MySQL configuration file
[Mysqld]
Datadir =/var/lib/mysql
Socket =/var/lib/mysql. sock
Old_passwords = 1 encode find this line add new rules in this line, let MySQL Default Encoding As UTF-8
Default-character-set = utf8 character add this line of code
[Root @ ywm/] # chkconfig mysqld on startup changes the startup information of the specified service mysqld. on and off specify the start and stop of the service respectively.
[Root @ ywm/] # chkconfig--list mysqld restart list the startup information of the system mysqld. If 2 ~ The status of 5 is OK when it is started.
Mysqld 0: Disable 1: Disable 2: Enable 3: Enable 4: Enable 5: Enable 6: Disable
[Root @ ywm/] #/etc/rc. d/init. d/mysqld start slave start Mysql System Service
Starting mysqld: [OK]
Now, the MySQL service settings of the system have been successfully started.

Set the database user password.
1. log on to the database first (use the super administrator's username and password mysql-u root. The default password for database installation is blank .) :

1 [root @ ywm/] # mysql-u root 2 mysql> select Host, User, Password from mysql. user; ← query the existing database username and Password 3 + ------ + -- + ---- + 4 | Host | User | Password | 5 + ------ + -- + ---- + 6 | localhost | root | 7 | ywm. localdomain | root | 8 | 127.0.0.1 | root | 9 | localhost | 10 | ywm. localdomain | 11 + ------ + -- + ---- + 12 5 rows in set (0.00 sec)

2. Use Database Programming to change the password of the database user name. The super administrator is root. Here, you need to change the username and password in two locations: @ localhost and @ ywm. localdomain (name of the host installation), and the password needs to be added to the corresponding data table using password ('new password') settings.

1 mysql> set password for root@localhost = password(‘sniper’);2 Query OK, 0 rows affected (0.00 sec)3 mysql> set password for root@ywm.localdomain = password(‘sniper’);4 Query OK, 0 rows affected (0.00 sec)

3. commands for exiting database settings.

Mysql> exit
Bye

Check whether the password in the database is correct.
1. log on to the database with an empty default password.
[Root @ ywm/] # mysql-u root
ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: NO)
2. log on to the database using a password that has been set and modified.
[Root @ ywm/] # mysql-u root-p
Enter password:
Mysql>
Successfully logged on to the database.

Related Article

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.