Database Reference
In-Depth Information
Connecting to the Server
Once you know your MySQLusername and password, you can connect to the MySQL
server with the mysql client. For instance, I gave myself the username russell so I can con-
nect as follows from a command line:
mysql -u russell -p
It's useful to understand each element of the previous line. The -u option is followed by
your username. Notice that the option and name are separated by a space. You would re-
place russell here with whatever username you've created for yourself. This is the
MySQL user, not the user for the operating system. Incidentally, it's not a good security
practice to use the root user, unless you have a specific administrative task to perform for
which only root has the needed privileges. So if you haven't created another user for your-
self, go back and do that now. To log into MariaDB, you would enter the same command
and options as for MySQL.
The -p option instructs the mysql client to prompt you for the password. You could add the
password to the end of the -p option (e.g., -pRover#My_1st_Dog&Not_Yours! ,
where the text after -p is the password). If you do this, leave no space between -p and the
password. However, entering the password on the command line is not a good security
practice either, because it displays the password on the screen (which others standing be-
hind you may see), and it transmits the password as clear text through the network, as well
as making it visible whenever someone gets a list of processes that are running on the serv-
er. It's better to give the -p option without the password and then enter the password when
asked by the server. Then the password won't be displayed on the screen or saved any-
where.
If you're logged into the server filesystem with the same username as you created for
MySQL, you won't need the -u option; the -p is all you'll need. You could then just enter
this:
mysql -p
Once you've entered the proper mysql command to connect to the server, along with the
password when prompted, you will be logged into MySQL or MariaDB through the client.
You will see something that looks like this:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1419341
Server version: 5.5.29 MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input
Search WWH ::




Custom Search