linux 下mysql二進制文件(tar.gz)安裝

二進制文件(tar.gz)安裝:
先創建用戶和用戶組
 su - root
groupadd mysql
useradd -g mysql mysql
解壓二進制文件。
gunzip -c filename | tar -xf -
複製目錄/home/mysql到/usr/local;
創建mysql許可表:
linux:/usr/local/mysql #scripts/mysql_install_db --user=mysql
設置二進制所有權,使之歸root所有,並屬於mysql所在管理組:
linux:/usr/local/mysql # chown -R root /usr/local/mysql
linux:/usr/local/mysql # chgrp -R mysql/usr/local/mysql
將數據目錄的所有權設置爲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
mysql>show databases;
最初只有兩個:test,information_schema;
以root身份登入則有四個。
運行命令bin/mysql -u root -p,此時將出現password:(要求輸入密碼),但默認情況下root用戶沒有密碼,所以回車即可。此時將進入MySQL界面,當然仍然只是個命令行窗口而以。
運行命令use test,將進入test數據庫
mysql>use test;
mysql> show tables
    -> ;
Empty set (0.00 sec)
建立一個地址簿數據庫:
mysql> create database address;
mysql> use 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)
mysql> insert into friends values
    -> (
    -> "myblue",
    -> "6743133"
    -> ,"464313113",
    -> "zhejiang");
Query OK, 1 row affected (0.00 sec)
mysql> select * from friends;
+--------+----------+-----------+----------+
| 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
Enter password:
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)
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql> update user set password=password('1234') where user='root';
mysql> FLUSH PRIVILEGES; 
mysql> exit
Bye
linux:/usr/local/mysql # bin/mysql -u root -p1234
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 20
Server version: 5.1.12-beta MySQL Community Server (GPL)
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql> 
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章