linux下mysql二進位檔案(tar.gz)安裝

來源:互聯網
上載者:User

先建立使用者和使用者組
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>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.