MySQL Administration
MySQL Administration
com
` ` ` ` `
Configuring Monitoring, Starting & Stopping Managing Users and Connection Performing backups Others
` `
` `
` `
Start MySQL process before create database To configure MySQL start at boot time
#chkconfig mysqld on
` `
The "mysqld is alive" message tells you that your MySQL server is running ok. If your MySQL server is not running, you will get a "connect ... failed" message.
my.cnf
Watch out for /etc/my.cnf, /etc/mysql/my.cnf
To get the server listening on all interfaces, use 0.0.0.0 as the bind address. i.e.: --bind-address=0.0.0.0
` `
Create a database
msql> create database [databasename];
Swicth to a database
msql> use [db_name];
To delete a db
msql> drop database [databasename];
To delete a table
msql> drop table [table name];
` ` ` ` ` ` `
SHOW TABLES; SHOW WARNINGS; SHOW STATUS; FLUSH STATUS; SHOW VARIABLES; SHOW VARIABLES LIKE %size%; SHOW VARIABLES LIKE sort_buffer_size; SHOW GLOBAL STATUS;
` `
According to the /etc/my.cnf Usually located in subdirectory /var/lib/mysql/ directory Example : test database
/var/lib/mysql/test
Root or superuser account is used to create and delete database New installation MySQL set password
#mysqladmin u root password new-password
to know what else you can do with "mysqladmin", you should run the "-?"
#mysqladmin ?
Allow the user bob to connect to server from localhost using password passwd
# mysql -u root -p mysql> use mysql; mysql> grant usage on *.* to bob@localhost identified by 'passwd'; mysql> flush privileges;
Example
mysql> create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default yasin'); mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));
` ` `