MySQLのcentos 6でのyumインストール使用
4791 ワード
環境:centos 6.7 32bit
データベースMySQLのインストール構成
1.インストール
2.起動
3.rootユーザー(この時点でパスワードはありません)によるログイン
現在のrootユーザーにパスワードがないことを確認します.
rootユーザーのパスワードをオペレーティングシステムのパスワードに設定します.
mysqlを終了し、rootユーザーを再使用してログインし、変更したパスワードを検証します.
データベース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 [email protected]=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