目录
1. 先检查系统是否装有mysql
[root@localhost ~]#yum list installed mysql*
[root@localhost ~]#rpm –qa|grep mysql*
2. 查看有没有安装包
[root@localhost ~]#yum list mysql*
3. 安装mysql客户端
[root@localhost ~]yum install mysql
4. 安装mysql服务端
[root@localhost ~]#yum install mysql-server
[root@localhost ~]#yum install mysql-devel
5. 在/etc/my.cnf 文件中加入默认字符集
[root@localhost ~]#vim /etc/my.cnf
6. 启动
[root@localhost ~]#service mysqld start --启动mysql 或者 /etc/init.d/mysqld start
7.关闭
[root@localhost ~]#service mysql stop
重启
service mysqld restart
查看状态
service mysqld status
8. 设置开机启动mysql服务
[root@localhost ~]# chkconfig --add mysqld
9. 创建root用户 密码为123456
[root@localhost ~]# mysqladmin -u root password 123456
10. 连接mysql
[root@localhost ~]# mysql -u root -p --回车然后输入密码123456
11. 设置远程访问权限
mysql> use mysql
mysql> GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%'IDENTIFIED BY 'admin' WITH GRANT OPTION;
--第一个admin为用户名,第二个admin为密码,%表示所有的电脑都可以链接
mysql> flush privileges; --设置立即生效
12.查看远程设置的如何
mysql> SELECT DISTINCT CONCAT('User:''',user,'''@''',host,''';') AS query FROM mysql.user;
mysql> exit; --退出mysql服务
13.设备地址设置一下
[root@localhost ~]# vi /etc/my.cnf
bind-address=0.0.0.0[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
default-character-set=utf8
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
bind-address=0.0.0.0 #设置设备地址
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
14.重启服务
[root@localhost ~]# service mysqld start --重启mysql服务
[root@localhost ~]# mysql -u root -p --连接mysql输入密码
mysql> show global variables like 'port'; --查看端口号
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3306 |
+---------------+-------+
1 row in set (0.00 sec)
15.用navcat test 连接mysql
16.关闭防火墙
service iptables stop
17.永久关闭防火墙
chkconfig iptables off
18.查看状态
service iptables status
ok
持续更新
标签:service,Centos,mysql,mysqld,Linux,yum,root,localhost
来源: https://blog.csdn.net/weixin_42749765/article/details/98781366