CentOS 7装mysql
程序员文章站
2022-04-15 11:52:32
安装mysql
centos 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载
echo "下载mysql的repo源&quo...
安装mysql
centos 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载
echo "下载mysql的repo源"
wget https://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm echo "安装rpm包" rpm -ivh mysql-community-release-el7-5.noarch.rpm echo "安装mysql" yum install mysql-community-server
成功安装之后重启mysql服务
# systemctl restart mysqld.service
初次安装mysql是root账户是没有密码的.
设置密码与远程登录
1.设置root的密码为mypassword,
2.将所有操作权限授予用户 ( 用户名为power && 密码为password && 来自任何ip )
# mysql -uroot mysql> use mysql; mysql> update user set password=password('mypassword') where user='root'; mysql> grant all privileges on *.* to 'power'@'%' identified by 'password' with grant option; mysql> flush privileges; mysql> exit;
修改mysql字符集编码
vim /etc/my.cnf [mysqld] init_connect=’set collation_connection = utf8_unicode_ci’ init_connect=’set names utf8’ character-set-server=utf8 collation-server=utf8_unicode_ci [client] default-character-set=utf8 [mysql] default-character-set=utf8
防火墙规则修改
firewall-cmd --permanent --add-port=3306/tcp firewall-cmd --reload
重启mysql重载生效配置
# systemctl restart mysqld.service
登录报错:
error 2002 (hy000): can‘t connect to local mysql server through socket‘/var/lib/mysql/mysql.sock‘ (2)
原因是/var/lib/mysql的访问权限问题。下面的命令把/var/lib/mysql的拥有者改为当前用户:
$ sudo chown -r mysql:mysql /var/lib/mysql
上一篇: ‘回忆’之 命运转折之旅 *
下一篇: 我在那曲,你在哪?
推荐阅读
-
CentOS7下二进制安装mysql 5.7.23
-
CentOS 7.x编译安装Nginx1.10.3+MySQL5.7.16+PHP5.2 5.3 5.4 5.5 5.6 7.0 7.1多版本全能环境
-
Win7下Redmine2.0.3+Mysql55+Ruby1.8.7成功安装记录分享
-
Windows7下安装使用MySQL8.0.16修改密码、连接Navicat问题
-
centos中mysql备份数据库脚本分享
-
详解Linux(centos7)下安装OpenSSL安装图文方法
-
Centos7 利用LVM实现动态扩容的方法
-
Centos7上网及添加静态IP方法介绍
-
linux中Centos7的LVM磁盘扩容问题
-
Linux中Centos7搭建Hadoop服务步骤