? (阿里云的yum仓库,里面的软件都是阿里云运维工程师定义的)
yum install mysql -y
-rpm -ivh mysqlxx.rpm
? (可以自定制软件的版本,以及可以最优先的使用最新版本软件)
? CentOS-Base.repo epel.repo
yum install mysql-server mysql -y
安装mysql的方式也有2种,阿里云官方提供的mariadb软件包,版本可能太低,但是下载网速很快,方便学习使用
在企业里面,多半不会使用阿里云的mariadb版本,因为版本太低,安全性太低,公司会配置myariadb官方的yum仓库.
touch Mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
yum install mariadb-server mariadb -y
systemctl start mariadb
mysql_secure_installation
修改mysql的配置文件,支持中文编码
cat /etc/my.cnf 和我一致就行
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
log-error=/var/log/mysqld.log # 配置文件
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
在服务器上,修改了配置文件,都要重启数据库服务
systemctl restart mariadb
在utf8编码下,配置mariadb
show create table stu;
show create database s16;
? 1. navicat
? 2. cmd
? mysql -uroot -p -h 192.168.15.53
? 3. pycharm
? 4. pymysql python
? 5. orm django
?
授权mariadb远程连接
授予root用户对所有的库表所有的权限,在所有的机器上操作,皆可登录
grant all privileges on *.* to root@‘%‘ identified by ‘zhang123...‘;
刷新授权表:
flush privileges;
mysqldump -u root -p --all-databases > /tmp/db.dump
数据导入,方式有2种
mysql -uroot -p < /tmp/db.dump
进入mysql命令行,输入source /tmp/db.dump
原文:https://www.cnblogs.com/zhang-zi-yi/p/10848120.html