centos7 mysql-server 安装过程
2023-09-11 14:19:35 时间
官网下载安装mysql-server
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # rpm -ivh mysql-community-release-el7-5.noarch.rpm # yum install mysql-community-server
安装成功后重启mysql服务。
# service mysqld restart
初次安装mysql,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>
不需要重启数据库即可生效。
在mysql安装过程中如下内容:
Installed:
mysql-community-client.x86_64 0:5.6.26-2.el7 mysql-community-devel.x86_64 0:5.6.26-2.el7
mysql-community-libs.x86_64 0:5.6.26-2.el7 mysql-community-server.x86_64 0:5.6.26-2.el7
Dependency Installed:
mysql-community-common.x86_64 0:5.6.26-2.el7
Replaced:
mariadb.x86_64 1:5.5.41-2.el7_0 mariadb-devel.x86_64 1:5.5.41-2.el7_0 mariadb-libs.x86_64 1:5.5.41-2.el7_0
mariadb-server.x86_64 1:5.5.41-2.el7_0
三、配置mysql
1、编码
mysql配置文件为/etc/my.cnf
最后加上编码配置
[mysql] default-character-set =utf8
这里的字符编码必须和/usr/share/mysql/charsets/Index.xml中一致。
2、远程连接设置
把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户。
mysql> grant all privileges on *.* to root@'%'identified by 'password';
如果是新用户而不是root,则要先新建用户
mysql>create user 'username'@'%' identified by 'password';
此时就可以进行远程连接了。
防火墙配置
防火墙设置一下,不然3306端口还是无法访问。
1 iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
设置完之后,查看一下是否能通过。
1 iptables -L -n
如果想要限制访问。
iptables -D INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
OK,这样就可以远程访问了。
来源:https://www.cnblogs.com/starof/p/4680083.html
相关文章
- 报错:MySQL Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
- file /usr/lib64/mysql/plugin/dialog.so from install of Percona-Server-server-56-5.6.24-rel72.2.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.60-1.el7_5.x86_64
- 【MySQL高级】MySql中常用工具及Mysql 日志
- Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2)
- MySQL使用初步—mysql数据库的基本命令
- Linux 上从 MySQL 迁移到 MariaDB 的简单步骤
- MySQL--Centos7.x MySQL5.7.x忘记root密码的解决方法
- 为啥MySQL官方不推荐使用uuid或者雪花id作为主键
- mysql 几阶b树_在学到MySQL索引时,涉及到了B树和B+树.聊一聊
- MySQL root修改普通用户密码及Mysql 修改root密码
- python 和 mysql连接
- ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061),mysql服务已启动
- Linux以rpm方式安装Mysql,Centos7通过rpm安装Mysql5.5,Linux Mysql rpm安装
- 转 zabbix+percona监控MySQL之各个监控项 V2
- 转发 可设置skip_name_resolve参数 会出现 ERROR 2005 (HY000): Unknown MySQL server host _mysql ...
- Mysql 5.7源码编译启动 报error问题:The server quit without updating PID file (/data/data_mysql/mysql.pid).
- Windows 免安装版mysql,适用于版本MySQL 5.7.7及以上,快速配置教程
- mysql 如何把查询到的结果插入到另一个表中
- mysql远程连接 Host is not allowed to connect to this MySQL server
- mysql导出数据报错The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
- 在centos7中用mariadb代替了mysql数据库吗
- 实践 —— 亲测从 RDS MySQL 通过数据集成导入 MaxCompute
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
- 在centos中php 在连接mysql的时候,出现Can't connect to MySQL server on 'XXX' (13)
- Amoeba for MySQL 非常好用的mysql集群软件
- CentOS7虚拟机下安装配置MySql、授权远程访问
- (5.4)mysql高可用系列——MySQL异步复制(实践)
- Linux 下安装mysql 5.7 --Centos7
- Go-MySQL-Driver:一个Go语言的轻量级极速的mysql驱动
- 【MySQL】CentOS7实现MySQL读写分离环境搭建
- Mysql 1290 - The MySQL server is running with the --secure-file-priv option
- mysql 获取所有的数据库名字
- 【MySQL】MySQL 发展历程和主流分支