Install MySQL in the 1.centos system using the Yum tool.
[[Email protected] ~] #yum install-y MySQL
2.yum install-y mysql, start MySQL error as follows:
ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/lib/mysql/mysql.sock ' (2)
Workaround: The component is missing and the Mysql-server package is installed.
3. Installing the Components Mysql-server
[[Email protected] ~] #yum install-y mysql-server
4. Start MySQL
[[Email protected] ~] #service mysqld Start
5. Using MySQL Error
[[email protected] ~]# MySQL
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)
6. Error resolution
(1) Service mysqld stop
(2)/usr/bin/mysqld_safe--skip-grant-tables
(3) Open an SSH connection separately
[[email protected] ~]# MySQL
Mysql> GRANT All privileges on * * to [email protected]'%' identified by ' root ';
mysql> usemysql
mysql>Update user set Password=password ("123456") where user= "root";
Mysql>flush Privileges;
Mysql>Exit
If there are errors as follows:
Mysql> GRANT All privileges on * * to [email protected] '% ' identified by ' root ';
ERROR 1290 (HY000): The MySQL server is running with the--skip-grant-tables option so it cannot execute this statement
Workaround: Enter flush privileges First, then GRANT all privileges on * * to [email protected]"% "Identified by" root; other steps do not forget.
(4) [[email protected] ~]#pkill-kill-t pts/0 can force a * * User of PTS 0 (user window previously running mysqld_safe) to kick out
(5) normal start MySQL:service mysqld start
If you use MySQL without starting the mysqld service, you will get an error:
[Email protected] ~]# mysql-u root-p
Enter Password:
ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/lib/mysql/mysql.sock ' (111)
7. Successfully entered MySQL
[Email protected] ~]# mysql-u root-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 5
Server version:5.1.73 Source Distribution
Copyright (c) and/or, Oracle, its affiliates. All rights reserved.
Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
mysql> show databases;
+----------------------+
| Database |
+----------------------+
| Information_schema |
| dbname |
| MySQL |
| Test |
+----------------------+
4 rows in Set (0.00 sec)
Mysql>
Safety tips:
GRANT all privileges on * * to [email protected] '% ' identified by ' root ';
This is the last to do IP or network segment restrictions, otherwise there is a security risk.
This article is from the "Feng Xiaoqing blog" blog, make sure to keep this source http://fengyunshan911.blog.51cto.com/995251/1747502
Yum install MySQL steps and error Error 1045 (28000)