So, to enter MySQL’s command-line interface, select Start→Run and enter CMD into the Run box, then press Return. This will call up a Windows Command prompt. From there, enter one of the following (making any appropriate changes as just discussed):
“C:\Program Files\Zend\MySQL51\bin” -u root
“C:\Program Files (x86)\Zend\MySQL51\bin” -u root
Note the quotation marks surrounding the path and filename. These are present because the name contains spaces, which the Command prompt doesn’t correctly interpret; the quotation marks group the parts of the filename into a single string for the Command program to understand.
This command tells MySQL to log you in as the user root, without a password. You will now be logged in to MySQL and can start entering commands. To be sure everything is working as it should be, enter the following—the results should be similar to.
SHOW databases;
If this has not worked and you get an error, make sure that you have correctly installed MySQL along with Zend Server CE.
OS X users
To proceed with this chapter, you should have installed Zend Server CE, you should also have the web server already running and the MySQL server started.
To enter the MySQL command-line interface, start the Terminal program (which should be available in Finder→Utilities). Then call up the MySQL program, which will have been installed in the directory /usr/local/zend/mysql/bin.
By default, the initial MySQL user is root and it will have a password of root too. So, to start the program, type the following:
/usr/local/zend/mysql/bin/mysql -u root
This command tells MySQL to log you in as the user root and not to request your password. To verify that all is well, type in the following—Figure 8-2 should be the result:
SHOW databases;
If you receive an error such as “Can’t connect to local MySQL server through socket,” you haven’t started up the MySQL server, so make sure you followed the advice in Chapter 2 about configuring MySQL to start when OS X starts.
Linux users
On a system running a Unix-like operating system such as Linux, you will almost certainly already have PHP and MySQL installed and running, and you will be able to enter the examples in the next section. But first, you should type the following to log in to your MySQL system:
mysql -u root -p
This tells MySQL to log you in as the user root and to request your password. If you have a password, enter it; otherwise, just press Return.
MySQL on a remote server
If you are accessing MySQL on a remote server, you should telnet (or preferably, for security, use SSH) into the remote machine, which will probably be a Linux/FreeBSD/Unix type of box. Once in there, things may be a little different for you, depending on how the system administrator has set up the server—especially if it’s a shared hosting server. Therefore, you need to ensure that you have been given access to MySQL and that you have your username and password. Armed with these, you can then type the following, where username is the name supplied:
mysql -u username -p
Sources for further reading
No comments yet (leave a comment)