quick mysql tutorial
I often have it that I need to have a database and user for a project.
Or maybe you need to install wordpress for a client.
What do you do?
- You want to use cli (command line interface) mysql.
In the shell prompt, try
# mysql
You might get in.
If you cannot, you may have a password set.
In that case you need to use the -p flag to be prompted for a password..
# mysql -p
Type in password and you should be in. - Great, you’re in. You see the ‘mysql>’ prompt.
Want to see what databases there are now?
mysql> show databases;
(Don’t forget the semicolon after every statement).Ok, we want to create database ‘junk’ for user ‘leo’..
mysql> CREATE DATABASE junk; - Now we need to make a user.. and allow them to use the database..
mysql> GRANT ALL ON metasum.* TO 'leo'@'localhost' IDENTIFIED BY 'slurp33';
Great, that should work.
If you were using perl and YAML::DBH, you do that, create a /etc/myconf.conf and in it place:
---
user: leo
password: slurp33
database: metasum
And then in your perl..
use YAML::DBH;
my $dbh = YAML::DBH::yaml_dbh('/etc/myconf.conf');
Yes, convenience rawks.
