MySQL: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| (9 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== Initial Configuration == | == Initial Configuration == | ||
{{Root| | {{Root|systemd-tmpfiles --create}} | ||
{{Root|/usr/ | {{Root|<nowiki>mysql_install_db --basedir=/usr --datadir=/var/lib/mysql --user=mysql</nowiki>}} | ||
{{Root|systemctl start mysql.service}} | |||
{{Root|mysql_secure_installation}} | |||
== Change the root password == | |||
{{Root|<nowiki>mysqladmin -u root password 'new-password'</nowiki>}} | |||
== Allow external connections, e.g. for phpMyAdmin == | |||
{{Root|mysql -u root -p}} | |||
{{Command|<nowiki>mysql> CREATE USER 'root'@'host.domain.local' IDENTIFIED BY 'xxx';</nowiki>}} | |||
{{Command|<nowiki>mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'host.domain.local' IDENTIFIED BY 'xxx' WITH GRANT OPTION;</nowiki>}} | |||
{{Command|<nowiki>mysql> FLUSH PRIVILEGES;</nowiki>}} | |||
== Dump == | |||
mysqldump -uroot -p -hlocalhost --databases --opt --allow-keywords --flush-logs --hex-blob --max_allowed_packet=16M --quote-names --result-file=database_backup.SQL database | |||
== Restore == | |||
cat database.SQL | mysql database -uroot -p -hlocalhost --max_allowed_packet=16M | |||
Latest revision as of 21:50, 24 April 2016
Initial Configuration
# systemd-tmpfiles --create
# mysql_install_db --basedir=/usr --datadir=/var/lib/mysql --user=mysql
# systemctl start mysql.service
# mysql_secure_installation
Change the root password
# mysqladmin -u root password 'new-password'
Allow external connections, e.g. for phpMyAdmin
# mysql -u root -p
$ mysql> CREATE USER 'root'@'host.domain.local' IDENTIFIED BY 'xxx';
$ mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'host.domain.local' IDENTIFIED BY 'xxx' WITH GRANT OPTION;
$ mysql> FLUSH PRIVILEGES;
Dump
mysqldump -uroot -p -hlocalhost --databases --opt --allow-keywords --flush-logs --hex-blob --max_allowed_packet=16M --quote-names --result-file=database_backup.SQL database
Restore
cat database.SQL | mysql database -uroot -p -hlocalhost --max_allowed_packet=16M