MYSQL

mysql安装

参考文章

通过yum方式安装mysql-server、mysql-devel、mysql

[root@sergs15 ~]# yum install -y mysql-server mysql-devel mysql
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
base                                                                                                           | 1.3 kB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.i386 0:5.0.77-4.el5_4.2 set to be updated
--> Processing Dependency: perl(DBI) for package: mysql
---> Package mysql.x86_64 0:5.0.77-4.el5_4.2 set to be updated
---> Package mysql-devel.i386 0:5.0.77-4.el5_4.2 set to be updated
---> Package mysql-devel.x86_64 0:5.0.77-4.el5_4.2 set to be updated
---> Package mysql-server.x86_64 0:5.0.77-4.el5_4.2 set to be updated
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server
--> Running transaction check
---> Package perl-DBD-MySQL.x86_64 0:3.0007-2.el5 set to be updated
---> Package perl-DBI.x86_64 0:1.52-2.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================
 Package                            Arch                       Version                                 Repository                Size
======================================================================================================================================
Installing:
 mysql                              i386                       5.0.77-4.el5_4.2                        base                     4.8 M
 mysql                              x86_64                     5.0.77-4.el5_4.2                        base                     4.8 M
 mysql-devel                        i386                       5.0.77-4.el5_4.2                        base                     2.4 M
 mysql-devel                        x86_64                     5.0.77-4.el5_4.2                        base                     2.5 M
 mysql-server                       x86_64                     5.0.77-4.el5_4.2                        base                     9.8 M
Installing for dependencies:
 perl-DBD-MySQL                     x86_64                     3.0007-2.el5                            base                     147 k
 perl-DBI                           x86_64                     1.52-2.el5                              base                     605 k

Transaction Summary
======================================================================================================================================
Install       7 Package(s)
Upgrade       0 Package(s)

Total download size: 25 M
Downloading Packages:
--------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                 4.8 GB/s |  25 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : perl-DBI                                                                                                       1/7 
  Installing     : mysql                                                                                                          2/7 
  Installing     : mysql                                                                                                          3/7 
  Installing     : perl-DBD-MySQL                                                                                                 4/7 
  Installing     : mysql-server                                                                                                   5/7 
  Installing     : mysql-devel                                                                                                    6/7 
  Installing     : mysql-devel                                                                                                    7/7 

Installed:
  mysql.i386 0:5.0.77-4.el5_4.2               mysql.x86_64 0:5.0.77-4.el5_4.2              mysql-devel.i386 0:5.0.77-4.el5_4.2      
  mysql-devel.x86_64 0:5.0.77-4.el5_4.2       mysql-server.x86_64 0:5.0.77-4.el5_4.2      

Dependency Installed:
  perl-DBD-MySQL.x86_64 0:3.0007-2.el5                                  perl-DBI.x86_64 0:1.52-2.el5                                 

Complete!

启动mysqld服务器

[root@sergs15 ~]# service mysqld start
Initializing MySQL database:  Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h sergs15.localdomain password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
[  OK  ]
Starting MySQL:  [  OK  ]
[root@sergs15 ~]# 

MYSQL启动问题解决

[root@gaosheng ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

参考文章

参考文章-01

参考文章-02

原文地址:https://www.cnblogs.com/arcer/p/3676570.html