![]() Creating the remote database Creating the local database OK, so now what? Deciding on fields Deciding on an index Creating the table Insert some data Querying the database Scripted querying Uploading onto the server |
Creating a local databaseIt is slightly more awkward to create the database on the local server if you are not experienced with command line programs. In order to create the database you need to use the program `mysqladmin', I will not go into all the command line parameters of this program or how it works, I will just supply a command which your should substitute the names of your database, username and password into, which will create the database for you and then set it up to work with your username and password. Before you can create the database you need to create the user with which you are going to access the database, to do this you need to use the mysql client, enter the mysql client using the following command - 'mysql -u root -p` or in windows 'mysql.exe -u root -p`, you will have to enter you superuser password for MySQL but once there you should see something like this. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 3.22.31 Type 'help' for help. mysql> If any of this does not work as referenced here then reference to the MySQL admin which should be able to answer your questions. At this point you are ready to create the user, use the following commands to do this (remember to substitute your values of the username and password); mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> insert into user values ('localhost','<username>',password('<password>'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); Query OK, 1 row affected (0.00 sec) You have now created the user with which you are going to access your database, now of course we have to create the database itself, type the following; $ mysqladmin -u root -p create <databasename> You should then see the following, just do what it asks; Enter password: Once your password has been entered you should have successfully created the database, before this can be used by our user we need to grant usage to our database that was just created, do this like so; mysql> use <databasename> Database changed mysql> grant all on * to <username> identified by "<password>"; Query OK, 0 rows affected (0.00 sec) In order to test this you can load the main MySQL client to test whether or not this is working; $ mysql -u <username> -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 3.22.31 Type 'help' for help. mysql> use <databasename>; Database changed If this happens then you have done everything correct and the database is ready for use, well done! You are now ready to create any tables and begin working with your database. |