linux上mysql二进制文件(tar.gz)安装

linux下mysql二进制文件(tar.gz)安装
ubuntu 安装mysql非常简单,如果你是ubuntu就直接运行:

要安装 MySQL,可以在终端提示符后运行下列命令:

sudo apt-get install mysql-server

sudo apt-get install mysql-client

sudo apt-get install php5-mysql
// 安装php5-mysql 是将php和mysql连接起来

一旦安装完成,MySQL 服务器应该自动启动。您可以在终端提示符后运行以下命令来检查 MySQL 服务器是否正在运行:

sudo netstat -tap | grep mysql

当您运行该命令时,您可以看到类似下面的行:

tcp 0 0 localhost.localdomain:mysql *:* LISTEN –

如果服务器不能正常运行,您可以通过下列命令启动它:

sudo /etc/init.d/mysql restart

进入mysql

mysql -uroot -p

(输入mysql的root密码)

配置 MySQL 的管理员密码:

sudo mysqladmin -u root password newpassword

下面才是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>

linux上mysql二进制文件(tar.gz)安装

相关文章:

你感兴趣的文章:

标签云: