二进制文件(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),qqChar(10), address VarChar(30));
ERROR 1064 (42000): You have an error in your SQL syntax; check themanual that corresponds to your MySQL server version for the rightsyntax to use near 'create table friends (name Char(15),telphoneVarChar(20),qq Char(10), address ' at line 1
mysql> create table friends (name Char(15),telphone VarChar(20),qqChar(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下安装配置 jdk7 + tomcat7 + mysql
- .Neter玩转Linux系列之六:Linux下MySQL的安装、配置、使用
- Linux下Nginx、MySQL、PHP5、phpMyAdmin安装与配置
- CentOS7 linux下yum安装mysql5.7
- linux tar.gz文件安装
- Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置
- Linux下安装-配置-mysql-5.7.13
- 在Linux系统中安装rpm,deb,tar.gz,tar.bz2,apt,bin 格式的文件
- 数据库----(linux下安装mysql-5.7.19(tar.gz)教程)
- linux下安装*.tar.gz和*.tar.bz2