Select Version, Current - Date : Create A Mysql Database
Select Version, Current - Date : Create A Mysql Database
mysql> SELECT * FROM my_table WHERE name = 'Smith AND age < 30; '> '\c mysql>
Note: If you have already set a password for the mysql root, you will need to use:
mysql -u root -p
For creating a new user with all privileges (use only for troubleshooting), at mysql prompt type:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
For creating a new user with fewer privileges (should work for most web applications) which can only use the database named "database1", at mysql prompt type:
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON database1.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword';
yourusername and yourpassword can be anything you like. database1 is the name of the database the user gets access to. localhost is the location which gets access to your database. You can change it to '%' (or to hostnames or ip addresses) to allow connections from every location (or only from specific locations) to the database. Note, that this can be a security problem and should only be used for testing purposes! To exit the mysql prompt type:
mysql> \q
Since the mysql root password is now set, if you need to use mysql again (as the mysql root), you will need to use:
mysql -u root -p
Backup-Settings
Please, let's say something in which directories mysql stores the database information and how to configure a backup
Alternatively
There is more than just one way to set the mysql root password and create a database. For example mysqladmin can be used:
mysqladmin -u root -p password yourpassword
and
mysqladmin -u root -p create database1