Create mysql database

To create database,



PHP Code: 
create database DB_NAME 
For example


PHP Code: 
mysqlcreate database video_vshare
Query OK1 row affected (0.01 sec

mysql



Creating mysql user account

To create a mysql user with all privileges on all databases.


PHP Code: 
GRANT ALL ON *.* TO 'USER_NAME'@'localhost' IDENTIFIED BY 'PASSWORD_HERE'
GRANT ALL ON *.* TO 'USER_NAME'@'%' IDENTIFIED BY 'PASSWORD_HERE';  
   
Create a user with permission to only one database
PHP Code: 
GRANT ALL ON DB_NAME.* to 'USER_NAME'@'localhost' IDENTIFIED BY 'PASSWORD_HERE'




Create MySQL User who can only Manage His Own DB

PHP Code: 
grant create on *.* to 'user'@'localhost' identified by 'pass'
FLUSH PRIVILEGES 
Repair mysql table

To repair table, you use to use the database.

PHP Code: 
mysql 
use freebb 
Now to check a table.
PHP Code: 
mysqlcheck table mithridates_sessions
+-----------------------------+-------+----------+----------------------------------------------------------+ 
Table                       Op    Msg_type Msg_text                                                 
+-----------------------------+-------+----------+----------------------------------------------------------+ 
mithridates_sessions check warning  Table is marked as crashed                               
mithridates_sessions check warning  6 clients are using or havent closed the table properly 
mithridates_sessions check error    Record at pos9519 is not remove-marked                 
mithridates_sessions check error    record delete-link-chain corrupted                       
mithridates_sessions check error    Corrupt                                                  
+-----------------------------+-------+----------+----------------------------------------------------------+ 
5 rows in set (0.05 sec)  
   
We found the table Corruptso repair it with repair table command.
     
PHP Code:      mysqlrepair table mithridates_sessions
+-----------------------------+--------+----------+--------------------------------------+ 
Table                       Op     Msg_type Msg_text                             
+-----------------------------+--------+----------+--------------------------------------+ 
mithridates_sessions repair warning  Number of rows changed from 94 to 95 
mithridates_sessions repair status   OK                                   
+-----------------------------+--------+----------+--------------------------------------+ 
2 rows in set (0.17 sec

mysql
Albert.Nawaro Reviewed by Albert.Nawaro on . Working with mysql-(1) Create mysql database To create database, create database DB_NAME For example Rating: 5