| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
8年前发布

centos6下MySQL的简单安装配置

环境:centos6.7 32bit

数据库MySQL的安装配置

1.安装

[root@cloudstack Desktop]# yum -y install mysql-server  Loaded plugins: fastestmirror, refresh-packagekit, security   .......  Dependency Installed:    mysql.i686 0:5.1.73-5.el6_6         perl-DBD-MySQL.i686 0:4.013-3.el6            perl-DBI.i686 0:1.609-4.el6          Complete!


[root@cloudstack Desktop]# yum -y install php-mysql  Loaded plugins: fastestmirror, refresh-packagekit, security  Setting up Install Process  ......  Installed:    php-mysql.i686 0:5.3.3-46.el6_6                                                 Dependency Installed:    php-common.i686 0:5.3.3-46.el6_6         php-pdo.i686 0:5.3.3-46.el6_6          Complete!

2.启动

[root@cloudstack Desktop]# /etc/rc.d/init.d/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 cloudstack.lyy.com 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  ]

3.通过root用户(此时并没有密码)登陆

[root@cloudstack Desktop]# mysql -u root  Welcome to the MySQL monitor.  Commands end with ; or \g.  Your MySQL connection id is 2  Server version: 5.1.73 Source distribution  Copyright (c) 2000, 2013, 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>

  查看当前root用户没有密码:

mysql> select user, host, password from mysql.user;  +------+--------------------+----------+  | user | host               | password |  +------+--------------------+----------+  | root | localhost          |          |  | root | cloudstack.lyy.com |          |  | root | 127.0.0.1          |          |  |      | localhost          |          |  |      | cloudstack.lyy.com |          |  +------+--------------------+----------+  5 rows in set (0.00 sec)

 设置root用户的密码为操作系统的密码:

mysql> set password for root@localhost=password('centos6');  Query OK, 0 rows affected (0.00 sec)  mysql> set password for root@cloudstack.lyy.com=password('centos6');  Query OK, 0 rows affected (0.00 sec)  mysql> select user, host, password from mysql.user;  +------+--------------------+-------------------------------------------+  | user | host               | password                                  |  +------+--------------------+-------------------------------------------+  | root | localhost          | *D53AD928B433F60B05A0B29CA1BCEA6809AC1B9D |  | root | cloudstack.lyy.com | *D53AD928B433F60B05A0B29CA1BCEA6809AC1B9D |  | root | 127.0.0.1          |                                           |  |      | localhost          |                                           |  |      | cloudstack.lyy.com |                                           |  +------+--------------------+-------------------------------------------+  5 rows in set (0.00 sec)  mysql> exit  Bye

 退出mysql,并重新使用root用户登录,验证修改后的密码。

[root@cloudstack Desktop]# mysql -u root  ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)  [root@cloudstack Desktop]# 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) 2000, 2013, 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> exit  Bye


来自: http://my.oschina.net/liuyuanyuangogo/blog/604088

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1453115992636.html
CentOS