MySQL database and user creation from the command line
On Agaric's test server, i need to log into MySQL as root to do these grant commands.
/usr/local/mysql/bin/mysql -uroot -p
On Debian, simply
mysql -uroot -p
worked. You have to put in your root password, of course. (And the lack of a space between -u and root is not a typo.)
In here, you can:
SHOW DATABASES;
CREATE DATABASE example_database;
GRANT ALL ON example_database.*
TO example_user@localhost IDENTIFIED BY 'p4ssw0rd';
Credit:
http://www.vbulletin.com/docs/html/main/cli_database
And quit
gets you out of there.
Related:
http://agaricdesign.com/backing-up-restoring-making-test-databases-with-mysql-command-line
A note about database names with dashes
It helps so much to use the correct commands. Dashed database names can be quoted with backticks (`), but be careful to include only the database and not the table wildcard when granting privileges.
If MySQL gives a "No database selected" error on a GRANT statement, that is a clue that something is wrong.
mysql> GRANT ALL PRIVILEGES ON `drupal-sdl-test.*` TO 'sdl';
ERROR 1046 (3D000): No database selected
mysql> GRANT ALL PRIVILEGES ON `drupal-sdl-test`.* TO 'sdl';
Query OK, 0 rows affected (0.14 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
Comments
Post new comment