时间:2021-07-01 10:21:17 帮助过:16人阅读
1. 查看mysql数据中,所有的用户名: use mysql; select distinct(User) from user; 2. Linux 执行 MySQL 脚本: mysql source/opt/app/swiftsync/sql/mysql/swiftsync_server.sql 3. Windows 执行MySQL脚本: mysql sourced:\test\ss.sql 4. MySQL授权其他
例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。
GRANT ALL PRIVILEGESON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANTOPTION;
如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALLPRIVILEGES ON *.* TO
参考:http://www.blogjava.net/acooly/archive/2008/09/17/229368.html
6. 创建数据库,用户,授权访问
$ /usr/local/mysql/bin/mysql -u root -p >create database cheersdb; >create user 'cheers'@'localhost' identified by 'cheerspassword'; >grant all privileges on cheersdb.* to 'cheers'@'localhost';
./mysqldump -h localhost -u root -p 数据库名>/opt/cheers/备份名称.sql
备份MySQL数据库为带删除表的格式,能够让该备份覆盖已有数据库而不需要手动删除原有数据库。
mysqldump -–add-drop-table -uusername -ppassword databasename> backupfile.sql
mysqldump -hhostname -uusername -ppassword databasename | gzip> backupfile.sql.gz
mysqldump -hhostname -uusername -ppassword databasenamespecific_table1 specific_table2 > backupfile.sql
mysqldump -hhostname -uusername -ppassword –databasesdatabasename1 databasename2 databasename3 >multibackupfile.sql
mysqldump –no-data –databases databasename1 databasename2databasename3 > structurebackupfile.sql
mysqldump –all-databases > allbackupfile.sql
mysql -h hostname-u username -p password databasename
举例:
root-pswiftsync_i6 ./mysql-h localhost -u swiftsync_i6为数据库名,你要导入的数据库名字。
/opt/app/db_backup/swiftsync_i5.sql为 备份文件的名字。
gunzip < backupfile.sql.gz | mysql -uusername-ppassword databasename
mysqldump -uusername -ppassword databasename | mysql–host=*.*.*.* -C databasename