centos 下yum 快速安装配置mysql
2017-01-04 00:00
344 查看
1.1在centos执行命令:
yum install -y mysql-server mysql mysql-deve
直到: Complete!。
1.2第一次启动mysql:(提示如何设置密码)
[root@hadoop1 hadoop]# service mysqld startInitializing 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 hadoop1 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 ]
1.3根据提示设置初始化密码:
[root@hadoop1 hadoop]# /usr/bin/mysqladmin -u root password 'root'提示错误如下
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
2.1解决不能正常登陆
2.1.1停止服务
[root@hadoop1 hadoop]# service mysqld stopStopping mysqld: [ OK ]
2.1.2安全模式启动
[root@hadoop1 hadoop]# mysqld_safe --skip-grant-tables &[1] 7371
[root@hadoop1 hadoop]# 170105 07:44:29 mysqld_safe Logging to '/var/log/mysqld.log'.
170105 07:44:29 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2.1.3无需账号密码登陆
mysql -uroot -pEnter password: #注释:直接回车就好
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
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.
2.1.4手动修改密码
mysql> use mysqlReading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set password=password("root") where user='root' and host='localhost';
Query OK, 1 row affected (0.03 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
2.1.5正常启动
[root@hadoop1 hadoop]# service mysqld restart170105 07:47:15 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root@hadoop1 hadoop]# mysql -uroot -proot
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>
3 解决客户端远程无法连接的问题
错误信息:Host '192.168.156.1' is not allowed to connect to this MySQL server解决办法:
3.1修改表
mysql> use mysql;mysql> update user set host = '%' where user = 'root';
mysql> select * from user where user='root' \G;
查看是否修改成功
3.2授权法
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.156.1' IDENTIFIED BY 'root' WITH GRANT OPTION;Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
相关文章推荐
- CentOS 6.5 yum安装配置lnmp服务器(Nginx+PHP+MySQL)+快速代理转发
- CentOS 6.4下通过YUM快速安装配置LAMP服务器(Apache+PHP5+MySQL)
- CentOS 6.2 yum安装配置lnmp服务器(Nginx+PHP+MySQL)
- CentOS 5.6服务器配置YUM安装Apache+php+Mysql+phpmyadmin
- CentOS 6.2 yum安装配置lnmp服务器(Nginx+PHP+MySQL)
- RHEL/CentOS 5.x使用yum快速安装MySQL 5.5.x
- CentOS 5.5服务器使用yum安装配置Apache、PHP和Mysql
- CentOS yum安装和配置MySQL(转载)
- (原创)RHEL/CentOS 5.x使用yum快速安装MySQL 5.5.x
- centos5.2 yum安装apache+mysql+php 配置wordpress
- CentOS 5.3上用yum快速安装Apache+php+Mysql+phpMyAdmin
- CentOS 5.4 服务器配置 yum安装Apache+php+Mysql
- CentOS 6.2 yum安装配置lnmp服务器(Nginx+PHP+MySQL)
- CentOS 5.4 服务器配置 yum安装Apache+php+Mysql+phpmyadmin
- CentOS 5.4 服务器配置 yum安装Apache+php+Mysql
- CentOS 5.6服务器配置YUM安装Apache+php+Mysql+phpmyadmin
- CentOS 6.* yum安装配置lnmp服务器(Nginx+PHP+MySQL)
- CentOS 6.2 yum安装配置lnmp服务器(Nginx+PHP+MySQL)
- CentOS 5.4 服务器配置 yum安装Apache+php+Mysql+phpmyadmin
- CentOS 5.x使用yum快速安装MySQL 5.5.X