MySQL Examples

 

Install mysql with yum

yum install mysql-server mysql
 
service mysqld start

Allow Remote Access

/etc/sysconfig/iptables:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
 
service iptables restart

Create Local User

CREATE USER 'layer7'@'localhost' IDENTIFIED BY 'welcome1';
 
GRANT ALL ON *.* TO 'layer7'@'localhost';
 
FLUSH privileges;

Create a Remote User

CREATE USER 'layer7'@'%' IDENTIFIED BY 'layer7';
 
GRANT ALL ON *.* TO 'layer7'@'%';
 
SET PASSWORD FOR 'layer7'@'%' = PASSWORD('welcome1');
 
FLUSH privileges;

Change User Password

SET PASSWORD FOR 'layer7'@'%' = PASSWORD('welcome1');
 
FLUSH privileges;

Create a Test Table

mysql -u root
 
show databases;
use test;
 
create table test_table(id varchar(6), name varchar(20), desc varchar(64));
insert into test_table values ('1', 'One');
show tables;
This entry was posted in mysql. Bookmark the permalink.

2 Responses to MySQL Examples

Leave a Reply

Your email address will not be published. Required fields are marked *


*

This site uses Akismet to reduce spam. Learn how your comment data is processed.