Bobby

导航

【DB】MySQL操作命令

1. 创建MySQL数据库

# mysql -uroot -p
MariaDB [(none)]> show databases;
MariaDB [(none)]> create database opstest DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
MariaDB [(none)]> grant all privileges on opstest.* to user@'%' identified by 'password';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit

2. 设置MySQL用户密码

# mysql_secure_installation
# mysqladmin -u root -password <new pass>

3. MySQL数据库导出和导入

# mysqldump -uroot -p <db name> > backup.sql
# mysql -uroot -p <db name> < backup.sql

 

posted on 2019-06-06 16:49  youth315  阅读(74)  评论(0)    收藏  举报