python 操作mysql 的网站:https://www.cnblogs.com/pycode/p/mysql-orm.html
1 修改MySQL的登录设置: # vi /etc/my.cnf 在[mysqld]的段中加上一句:skip-grant-tables 例如: [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock skip-grant-tables 保存并且退出vi。 2.重新启动mysqld # /etc/init.d/mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ] 3.登录并修改MySQL的root密码 # /usr/bin/mysql
mysql> use mysql;
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
/etc/init.d/mysql restart mysql -u root -p Enter password: <输入新设的密码newpassword> mysql>
4 创建用户
create user 'kobe'@'localhost' identified by 'admin@123'; 将localhost 改为%s 表示外网能够访问。
5 创建数据库
create databases kobesystem
6 对用户设置权限
GRANT ALL PRIVILEGES ON *.* TO 'kobe'@'%' IDENTIFIED BY 'Admin@123' WITH GRANT OPTION;
7 将数据库和用户绑定
grant all privileges on haildb.* to hail@localhost identified by 'hail';haildb 为数据库,hail 为用户hail 为密码转载于:https://www.cnblogs.com/liupeng520/p/6547642.html