先創建用戶和用戶組
su - root
groupadd mysql
useradd -g mysql mysql
gunzip -c filename | tar -xf -
linux:/usr/local/mysql #scripts/mysql_install_db --user=mysql
linux:/usr/local/mysql # chown -R root /usr/local/mysql
linux:/usr/local/mysql # chgrp -R mysql/usr/local/mysql
linux:/usr/local/mysql # chown -R mysql /usr/local/mysql/data
linux:/usr/local/mysql # bin/mysqld_safe --user=mysql &
linux:/usr/local/mysql # bin/mysql -u mysql
最初只有兩個:test,information_schema;
以root身份登入則有四個。
mysql>use test;
-> ;
Empty set (0.00 sec)
mysql> create database address;
Database changed
mysql> create table friends (name Char(15),telphone VarChar(20),qq Char(10), address VarChar(30));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'create table friends (name Char(15),telphone VarChar(20),qq Char(10), address ' at line 1
mysql> create table friends (name Char(15),telphone VarChar(20),qq Char(10), address VarChar(30));
Query OK, 0 rows affected (0.01 sec)
新增幾筆資料,並查詢看看:
mysql> insert into friends values("xyf","123456","359830463","浙江");
Query OK, 1 row affected (0.00 sec)
-> (
-> "myblue",
-> "6743133"
-> ,"464313113",
-> "zhejiang");
Query OK, 1 row affected (0.00 sec)
+--------+----------+-----------+----------+
| name | telphone | qq | address |
+--------+----------+-----------+----------+
| xyf | 123456 | 359830463 | 浙江 |
| myblue | 6743133 | 464313113 | zhejiang |
+--------+----------+-----------+----------+
2 rows in set (0.00 sec)
#在控制檯上輸入
linux:/usr/local/mysql # bin/mysql -u root -p
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 18
Server version: 5.1.12-beta MySQL Community Server (GPL)
mysql> FLUSH PRIVILEGES;
mysql> exit
Bye
Your MySQL connection id is 20
Server version: 5.1.12-beta MySQL Community Server (GPL)