Centos上安装Mysql

来源:互联网 发布:vscode svn插件 编辑:程序博客网 时间:2024/05/29 17:48

操作系统信息:

[vagrant@localhost ~]$ uname -a

Linux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux


1、sudo yum install Percona-Server-shared-55-5.5.37-rel35.0.el6.x86_64.rpm 

[vagrant@localhost download]$ sudo yum install Percona-Server-shared-55-5.5.37-rel35.0.el6.x86_64.rpm 

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * base: ftp.riken.jp

 * extras: ftp.riken.jp

 * updates: ftp.riken.jp

Setting up Install Process

Examining Percona-Server-shared-55-5.5.37-rel35.0.el6.x86_64.rpm: Percona-Server-shared-55-5.5.37-rel35.0.el6.x86_64

Marking Percona-Server-shared-55-5.5.37-rel35.0.el6.x86_64.rpm to be installed

Resolving Dependencies

--> Running transaction check

---> Package Percona-Server-shared-55.x86_64 0:5.5.37-rel35.0.el6 will be installed

--> Processing Dependency: libcrypto.so.10(libcrypto.so.10)(64bit) for package: Percona-Server-shared-55-5.5.37-rel35.0.el6.x86_64

--> Processing Dependency: libssl.so.10(libssl.so.10)(64bit) for package: Percona-Server-shared-55-5.5.37-rel35.0.el6.x86_64

--> Running transaction check

---> Package openssl.x86_64 0:1.0.0-27.el6_4.2 will be updated

--> Processing Dependency: openssl = 1.0.0-27.el6_4.2 for package: openssl-devel-1.0.0-27.el6_4.2.x86_64

---> Package openssl.x86_64 0:1.0.1e-30.el6_6.5 will be an update

--> Running transaction check

---> Package openssl-devel.x86_64 0:1.0.0-27.el6_4.2 will be updated

---> Package openssl-devel.x86_64 0:1.0.1e-30.el6_6.5 will be an update

--> Finished Dependency Resolution


Dependencies Resolved


==============================================================================================================

 Package                  Arch   Version            Repository                                           Size

==============================================================================================================

Installing:

 Percona-Server-shared-55 x86_64 5.5.37-rel35.0.el6 /Percona-Server-shared-55-5.5.37-rel35.0.el6.x86_64 3.0 M

Updating for dependencies:

 openssl                  x86_64 1.0.1e-30.el6_6.5  updates                                             1.5 M

 openssl-devel            x86_64 1.0.1e-30.el6_6.5  updates                                             1.2 M


Transaction Summary

==============================================================================================================

Install       1 Package(s)

Upgrade       2 Package(s)


Total size: 5.6 M

Total download size: 2.7 M

Is this ok [y/N]: y

Downloading Packages:

(1/2): openssl-1.0.1e-30.el6_6.5.x86_64.rpm                                            | 1.5 MB     00:05     

(2/2): openssl-devel-1.0.1e-30.el6_6.5.x86_64.rpm                                      | 1.2 MB     00:06     

--------------------------------------------------------------------------------------------------------------

Total                                                                         225 kB/s | 2.7 MB     00:12     

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Updating   : openssl-1.0.1e-30.el6_6.5.x86_64                                                           1/5 

  Installing : Percona-Server-shared-55-5.5.37-rel35.0.el6.x86_64                                         2/5 

  Updating   : openssl-devel-1.0.1e-30.el6_6.5.x86_64                                                     3/5 

  Cleanup    : openssl-devel-1.0.0-27.el6_4.2.x86_64                                                      4/5 

  Cleanup    : openssl-1.0.0-27.el6_4.2.x86_64                                                            5/5 

  Verifying  : openssl-1.0.1e-30.el6_6.5.x86_64                                                           1/5 

  Verifying  : Percona-Server-shared-55-5.5.37-rel35.0.el6.x86_64                                         2/5 

  Verifying  : openssl-devel-1.0.1e-30.el6_6.5.x86_64                                                     3/5 

  Verifying  : openssl-devel-1.0.0-27.el6_4.2.x86_64                                                      4/5 

  Verifying  : openssl-1.0.0-27.el6_4.2.x86_64                                                            5/5 


Installed:

  Percona-Server-shared-55.x86_64 0:5.5.37-rel35.0.el6                                                        


Dependency Updated:

  openssl.x86_64 0:1.0.1e-30.el6_6.5                 openssl-devel.x86_64 0:1.0.1e-30.el6_6.5                


Complete!


2、sudo yum install Percona-Server-devel-55-5.5.37-rel35.0.el6.x86_64.rpm 

[vagrant@localhost download]$ sudo yum install Percona-Server-devel-55-5.5.37-rel35.0.el6.x86_64.rpm 

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * base: ftp.riken.jp

 * extras: ftp.riken.jp

 * updates: ftp.riken.jp

Setting up Install Process

Examining Percona-Server-devel-55-5.5.37-rel35.0.el6.x86_64.rpm: Percona-Server-devel-55-5.5.37-rel35.0.el6.x86_64

Marking Percona-Server-devel-55-5.5.37-rel35.0.el6.x86_64.rpm to be installed

Resolving Dependencies

--> Running transaction check

---> Package Percona-Server-devel-55.x86_64 0:5.5.37-rel35.0.el6 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


==============================================================================================================

 Package                 Arch   Version              Repository                                          Size

==============================================================================================================

Installing:

 Percona-Server-devel-55 x86_64 5.5.37-rel35.0.el6   /Percona-Server-devel-55-5.5.37-rel35.0.el6.x86_64 4.4 M


Transaction Summary

==============================================================================================================

Install       1 Package(s)


Total size: 4.4 M

Installed size: 4.4 M

Is this ok [y/N]: y

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : Percona-Server-devel-55-5.5.37-rel35.0.el6.x86_64                                          1/1 

  Verifying  : Percona-Server-devel-55-5.5.37-rel35.0.el6.x86_64                                          1/1 


Installed:

  Percona-Server-devel-55.x86_64 0:5.5.37-rel35.0.el6                                                         



3、sudo yum install Percona-Server-client-55-5.5.37-rel35.0.el6.x86_64.rpm 

[vagrant@localhost download]$ sudo yum install Percona-Server-client-55-5.5.37-rel35.0.el6.x86_64.rpm 

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * base: ftp.riken.jp

 * extras: ftp.riken.jp

 * updates: ftp.riken.jp

Setting up Install Process

Examining Percona-Server-client-55-5.5.37-rel35.0.el6.x86_64.rpm: Percona-Server-client-55-5.5.37-rel35.0.el6.x86_64

Marking Percona-Server-client-55-5.5.37-rel35.0.el6.x86_64.rpm to be installed

Resolving Dependencies

--> Running transaction check

---> Package Percona-Server-client-55.x86_64 0:5.5.37-rel35.0.el6 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


==============================================================================================================

 Package                  Arch   Version            Repository                                           Size

==============================================================================================================

Installing:

 Percona-Server-client-55 x86_64 5.5.37-rel35.0.el6 /Percona-Server-client-55-5.5.37-rel35.0.el6.x86_64  29 M


Transaction Summary

==============================================================================================================

Install       1 Package(s)


Total size: 29 M

Installed size: 29 M

Is this ok [y/N]: y

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : Percona-Server-client-55-5.5.37-rel35.0.el6.x86_64                                         1/1 

  Verifying  : Percona-Server-client-55-5.5.37-rel35.0.el6.x86_64                                         1/1 


Installed:

  Percona-Server-client-55.x86_64 0:5.5.37-rel35.0.el6                                                        


Complete!


4、sudo yum install Percona-Server-server-55-5.5.37-rel35.0.el6.x86_64.rpm

[vagrant@localhost download]$ sudo yum install Percona-Server-server-55-5.5.37-rel35.0.el6.x86_64.rpm

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * base: ftp.riken.jp

 * extras: ftp.riken.jp

 * updates: ftp.riken.jp

Setting up Install Process

Examining Percona-Server-server-55-5.5.37-rel35.0.el6.x86_64.rpm: Percona-Server-server-55-5.5.37-rel35.0.el6.x86_64

Marking Percona-Server-server-55-5.5.37-rel35.0.el6.x86_64.rpm to be installed

Resolving Dependencies

--> Running transaction check

---> Package Percona-Server-server-55.x86_64 0:5.5.37-rel35.0.el6 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


==============================================================================================================

 Package                  Arch   Version            Repository                                           Size

==============================================================================================================

Installing:

 Percona-Server-server-55 x86_64 5.5.37-rel35.0.el6 /Percona-Server-server-55-5.5.37-rel35.0.el6.x86_64  65 M


Transaction Summary

==============================================================================================================

Install       1 Package(s)


Total size: 65 M

Installed size: 65 M

Is this ok [y/N]: y

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : Percona-Server-server-55-5.5.37-rel35.0.el6.x86_64                                         1/1 

Error in my_thread_global_end(): 1 threads didn't exit

Error in my_thread_global_end(): 1 threads didn't exit


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 localhost.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.


Please report any problems at

  https://bugs.launchpad.net/percona-server/+filebug


Percona recommends that all production deployments be protected with a support

contract (http://www.percona.com/mysql-suppport/) to ensure the highest uptime,

be eligible for hot fixes, and boost your team's productivity.

Percona Server is distributed with several useful UDF (User Defined Function) from Percona Toolkit.

Run the following commands to create these functions:

mysql -e "CREATE FUNCTION fnv1a_64 RETURNS INTEGER SONAME 'libfnv1a_udf.so'"

mysql -e "CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME 'libfnv_udf.so'"

mysql -e "CREATE FUNCTION murmur_hash RETURNS INTEGER SONAME 'libmurmur_udf.so'"

See http://www.percona.com/doc/percona-server/5.5/management/udf_percona_toolkit.html for more details

  Verifying  : Percona-Server-server-55-5.5.37-rel35.0.el6.x86_64                                         1/1 


Installed:

  Percona-Server-server-55.x86_64 0:5.5.37-rel35.0.el6                                                        


Complete!


5、启动mysql

[vagrant@localhost download]$ chkconfig --list | grep mysql

mysql          0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭

[vagrant@localhost download]$ sudo service mysql start

Starting MySQL (Percona Server)..... SUCCESS! 

[vagrant@localhost download]$ sudo netstat -ntlp | grep mysql

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      2768/mysqld         

6、创建mysql 用户

非root创建失败。

[vagrant@localhost ~]$ mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.5.37-35.0 Percona Server (GPL), Release rel35.0, Revision 657


Copyright (c) 2009-2014 Percona LLC and/or its affiliates

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> CREATE USER dummy IDENTIFIED BY '123';

ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation

root权限创建成功。

[vagrant@localhost ~]$ sudo mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.5.37-35.0 Percona Server (GPL), Release rel35.0, Revision 657


Copyright (c) 2009-2014 Percona LLC and/or its affiliates

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> CREATE USER dummy IDENTIFIED BY '123';

Query OK, 0 rows affected (0.03 sec)


mysql> GRANT ALL ON *.* TO dummy;

Query OK, 0 rows affected (0.01 sec)

7、用新增用户登录mysql

[vagrant@localhost ~]$ sudo mysql -udummy -p

Enter password: 

ERROR 1045 (28000): Access denied for user 'dummy'@'localhost' (using password: YES)

晕。。。。。。新增用户无法登录数据库。。。。。


原因暂时未找到。。。

继续用默认的root的账号。


----------------------------------------------------------------------------------------------------------

续:给root账户设定密码

输入mysql_secure_installation,设定密码,删除测试数据库,匿名账户,一路按”Y”就可以了(生产环境,为了安全,必须要这么做的)

[vagrant@localhost ~]$ mysql_secure_installation 





NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!



In order to log into MySQL to secure it, we'll need the current

password for the root user.  If you've just installed MySQL, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.


Enter current password for root (enter for none): 

OK, successfully used password, moving on...


Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation.


Set root password? [Y/n] Y

New password: 

Re-enter new password: 

Password updated successfully!

Reloading privilege tables..

 ... Success!



By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.


Remove anonymous users? [Y/n] Y

 ... Success!


Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.


Disallow root login remotely? [Y/n] Y

 ... Success!


By default, MySQL comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.


Remove test database and access to it? [Y/n] Y

 - Dropping test database...

 ... Success!

 - Removing privileges on test database...

 ... Success!


Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.


Reload privilege tables now? [Y/n] Y

 ... Success!


Cleaning up...




All done!  If you've completed all of the above steps, your MySQL

installation should now be secure.


Thanks for using MySQL!




0 0