centos 环境中部署mysql

仅以此片记录在centos环境中布置mysql,安装流程非常顺利,如果大家在安装或使用过程中发生意外问题,请自行搜索其他资料解决。
一、安装mysql
使用yum安装,根据自己的需求安装下面三个安装包,
1.客户端
2.服务端
3.开发专用
#yum install mysql
#yum install mysql-server
#yum install mysql-devel
二、启动mysql
# service mysqld start
三、修改mysql密码
初次安装mysql,不设置密码,可以通过 mysql -u root 直接进入
[root@yl-web yl]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.01 sec)

进入mysql后通过修改表格,设置密码
mysql> set password for 'root'@'localhost' =password('password');
Query OK, 0 rows affected (0.00 sec)

mysql>
四、远程连接设置

  1. 改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"

mysql -u root -pvmwaremysql>use mysql;mysql>update user set host = '%' where user = ``'root';mysql>select host, user from user;

  1. 授权法。例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH ``GRANT OPTION;

如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' ``WITH GRANT OPTION;

你可能感兴趣的:(centos 环境中部署mysql)