mysql

centos mysql

安装

https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/

# 下载 rpm <https://dev.mysql.com/downloads/repo/yum/>
$ wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
# 安装 rpm
$ sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm
# 安装 mysql
$ sudo yum install mysql-community-server

注意:centos7 选择 Red Hat Enterprise Linux 7.


mysql5.7之后,首次登录操作如下:

# 获取首次登录密码
$ sudo grep 'temporary password' /var/log/mysqld.log
# 用获取的密码登录
$ mysql -uroot -p
# 修改密码
$ ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

https://dev.mysql.com/doc/refman/5.7/en/using-systemd.html

 

报错:1130-host ... is not allowed to connect to this MySql server

原因:登录账号只允许 localhost 登录,需要修改账号远程登录权限。https://www.cnblogs.com/xyzdw/archive/2011/08/11/2135227.html

mysql> use mysql;

mysql> update user set host = '%' where user = 'root';

mysql> select host, user from user;

mysql> FLUSH   PRIVILEGES;

记得一定要flush privileges!!! 修改才能生效!

 

# 2019/5/22

python mysql-connector

Authentication plugin 'caching_sha2_password' is not supported python

mysql 8 用户认证插件默认采用 caching_sha2_password,而 mysql-connector 采用的是 mysql_native_password 编码,导致错误。

解决办法:

pip uninstall mysql-connector
pip install mysql-connector-python

https://stackoverflow.com/questions/50557234/authentication-plugin-caching-sha2-password-is-not-supported

 

# 2019/6/4

mysql 导出表结构:

# dbname 为要导出表结构的数据库名称
mysqldump -u root -p -d dbname >db.sql

mysql 导出数据:

# dbname 为要导出数据的数据库名
mysqldump -u root -p dbname >db.sql

https://www.cnblogs.com/yuanyouqi/archive/2010/04/28/1722738.html

posted @ 2019-05-07 22:32  kendi  阅读(175)  评论(0)    收藏  举报