|
|
Database connections List of Categories
- How do I log in to MySQL?
- How do I connect to a MySQL database on a remote server?
-
How do I log in to MySQL?
You need the root or mysql username and password to log in to MySQL using Telnet or an SSH client. This then allows you to perform queries at the command prompt. At the command prompt, type
mysql -u username -p
Enter password when prompted. Once logged in, you can list all available databases by typing :
SHOW DATABASES;
Create a Database by typing :
CREATE DATABASE databasename;
and add users to a database by typing
GRANT ALL PRIVILEGES ON databasename.* TO newuser@"%" IDENTIFIED BY "newpassword";
The above statement would grant all available privileges to the new user who could connect to the server from any domain. When entering statements at the command prompt, you must terminate them with a semi-colon ;
-
How do I connect to a MySQL database on a remote server?
You can set up database to allow connections from only the server it resides on (localhost), from a specific domain (remotedomain.com) or from any domain (%).
GRANT ALL PRIVILEGES ON databasename.* TO
user@localhost IDENTIFIED BY "password"
GRANT ALL PRIVILEGES ON databasename.* TO
user@remotedomain.com IDENTIFIED BY "password"
GRANT ALL PRIVILEGES ON databasename.* TO
user@"%" IDENTIFIED BY "password"
|
|
|