Difference between revisions of "MariaDB/MySQL"

From wiki
Jump to navigation Jump to search
(Created page with "[https://mariadb.org/ MariaDB] is an open source fork of [http://www.mysql.com/ MySQL]. There are some differences but most are internal, for users the commands and SQL syntax...")
 
Line 5: Line 5:
 
=Move users from one server to another=
 
=Move users from one server to another=
  
Starting on the source server execute following commands
+
Starting on the source server execute this script
 
<syntaxhighlight lang=bash>
 
<syntaxhighlight lang=bash>
mysql -B -N -uroot -p -e "SELECT CONCAT('\'', user,'\'@\'', host, '\'') FROM user WHERE user IN ('username1', 'username2', 'username3')" > users.txt
+
PASSWORD=$1
 +
mysql -B -N -uroot -p${PASSWORD} -e "SELECT CONCAT('\'', user,'\'@\'', host, '\'') FROM user WHERE user IN ('username1', 'username2', 'username3')" > users.txt
 
while read line
 
while read line
 
  do
 
  do
   mysql -B -N -uroot -p -e "SHOW GRANTS FOR $line"
+
   mysql -B -N -uroot -p${PASSWORD} -e "SHOW GRANTS FOR $line"
 
  done < users.txt > users.sql
 
  done < users.txt > users.sql
 
sed -i 's/$/;/' users.sql
 
sed -i 's/$/;/' users.sql
 +
</syntaxhighlight>
  
# Move the file to the other server and there do
+
Move the file to the other server and there do:
  
mysql -u root -p < users.sql
+
<code>mysql -u root -p < users.sql</code>
</syntaxhighlight>
 

Revision as of 22:03, 13 October 2019

MariaDB is an open source fork of MySQL. There are some differences but most are internal, for users the commands and SQL syntax is exactly the same.

phpMyAdmin is a web based GUI for the maintenance of MariaDB and MySQL servers.

Move users from one server to another

Starting on the source server execute this script

PASSWORD=$1
mysql -B -N -uroot -p${PASSWORD} -e "SELECT CONCAT('\'', user,'\'@\'', host, '\'') FROM user WHERE user IN ('username1', 'username2', 'username3')" > users.txt
while read line
 do
  mysql -B -N -uroot -p${PASSWORD} -e "SHOW GRANTS FOR $line"
 done < users.txt > users.sql
sed -i 's/$/;/' users.sql

Move the file to the other server and there do:

mysql -u root -p < users.sql