how to copy all mysql users manually?

rastoma

Well-Known Member
Aug 27, 2001
158
0
316
If a drive is too full and I can't run backups, I want to copy the entire /var/lib/mysql directory but that doesn't copy db users and permissions.

Where is the db user data located?
 

JaredR.

Well-Known Member
Feb 25, 2010
1,834
23
143
Houston, TX
cPanel Access Level
Root Administrator
Make a dump of the MySQL database

As yapluka mentioned, these data are in the mysql database. The best way to preserve these data is to make a dump of the mysql database, which will create a file that contains all of the commands needed to create the database again. A very basic use of the mysqldump command would be the following:

Code:
# mysqldump mysql > /root/mysql.sql
This will create a dump file in /root, mysql.sql, that contains all of the SQL statements needed to create the mysql database again. To import the database in the future, simply redirect the dump file into MySQL:

Code:
# mysql mysql < /root/mysql.sql
If you need to move the MySQL data directory due to lack of disk space, there are several threads in our forums that describe how to do this. A couple of good suggestions are the following:

http://forums.cpanel.net/f5/move-mysql-databases-6655.html
cPanel Forums - View Single Post - Move MySQL Databases
http://forums.cpanel.net/f5/how-move-mysql-data-folder-110481.html