LNMP环境搭建之二--mysql

安装 MySQL

[root@VM_88_143_centos ~]# yum install mysql-server -y
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.x86_64 0:5.1.73-8.el6_8 will be installed
--> Processing Dependency: mysql = 5.1.73-8.el6_8 for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: perl-DBI for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.73-8.el6_8.x86_64
--> Running transaction check
---> Package mysql.x86_64 0:5.1.73-8.el6_8 will be installed
--> Processing Dependency: mysql-libs = 5.1.73-8.el6_8 for package: mysql-5.1.73-8.el6_8.x86_64
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
--> Running transaction check
---> Package mysql-libs.x86_64 0:5.1.73-7.el6 will be updated
---> Package mysql-libs.x86_64 0:5.1.73-8.el6_8 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================================
 Package                                           Arch                                      Version                                             Repository                             Size
=============================================================================================================================================================================================
Installing:
 mysql-server                                      x86_64                                    5.1.73-8.el6_8                                      os                                    8.6 M
Installing for dependencies:
 mysql                                             x86_64                                    5.1.73-8.el6_8                                      os                                    895 k
 perl-DBD-MySQL                                    x86_64                                    4.013-3.el6                                         os                                    134 k
 perl-DBI                                          x86_64                                    1.609-4.el6                                         os                                    705 k
Updating for dependencies:
 mysql-libs                                        x86_64                                    5.1.73-8.el6_8                                      os                                    1.2 M

Transaction Summary
=============================================================================================================================================================================================
Install       4 Package(s)
Upgrade       1 Package(s)

Total download size: 12 M
Downloading Packages:
(1/5): mysql-5.1.73-8.el6_8.x86_64.rpm                                                                                                                                | 895 kB     00:00     
(2/5): mysql-libs-5.1.73-8.el6_8.x86_64.rpm                                                                                                                           | 1.2 MB     00:00     
(3/5): mysql-server-5.1.73-8.el6_8.x86_64.rpm                                                                                                                         | 8.6 MB     00:00     
(4/5): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm                                                                                                                          | 134 kB     00:00     
(5/5): perl-DBI-1.609-4.el6.x86_64.rpm                                                                                                                                | 705 kB     00:00     
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                         29 MB/s |  12 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : mysql-libs-5.1.73-8.el6_8.x86_64                                                                                                                                          1/6 
  Installing : perl-DBI-1.609-4.el6.x86_64                                                                                                                                               2/6 
  Installing : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                                                                                         3/6 
  Installing : mysql-5.1.73-8.el6_8.x86_64                                                                                                                                               4/6 
  Installing : mysql-server-5.1.73-8.el6_8.x86_64                                                                                                                                        5/6 
  Cleanup    : mysql-libs-5.1.73-7.el6.x86_64                                                                                                                                            6/6 
  Verifying  : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                                                                                         1/6 
  Verifying  : mysql-server-5.1.73-8.el6_8.x86_64                                                                                                                                        2/6 
  Verifying  : perl-DBI-1.609-4.el6.x86_64                                                                                                                                               3/6 
  Verifying  : mysql-5.1.73-8.el6_8.x86_64                                                                                                                                               4/6 
  Verifying  : mysql-libs-5.1.73-8.el6_8.x86_64                                                                                                                                          5/6 
  Verifying  : mysql-libs-5.1.73-7.el6.x86_64                                                                                                                                            6/6 

Installed:
  mysql-server.x86_64 0:5.1.73-8.el6_8                                                                                                                                                       

Dependency Installed:
  mysql.x86_64 0:5.1.73-8.el6_8                               perl-DBD-MySQL.x86_64 0:4.013-3.el6                               perl-DBI.x86_64 0:1.609-4.el6                              

Dependency Updated:
  mysql-libs.x86_64 0:5.1.73-8.el6_8                                                                                                                                                         

Complete!

安装完成后,启动 MySQL 服务:

[root@VM_88_143_centos ~]# service mysqld restart
Stopping mysqld:                                           [  OK  ]
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 VM_88_143_centos 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 /usr/mysql-test ; perl mysql-test-run.pl

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

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

设置 MySQL 账户 root 密码:

[root@VM_88_143_centos ~]# /usr/bin/mysqladmin -u root password 'MyPas$word4Word_Press'

将 MySQL 设置为开机自动启动:

[root@VM_88_143_centos ~]# chkconfig mysqld on
[root@VM_88_143_centos ~]# ps -ef | grep mysql
root      3092     1  0 21:02 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql     3194  3092  0 21:02 pts/0    00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root      3281  2318  0 21:03 pts/0    00:00:00 grep mysql


猜你喜欢

转载自blog.csdn.net/kongshuai19900505/article/details/78827564