安装mysql

1.安装个cmake

2.将两个目录,一个是安装目录,一个数据存放目录

[root@ rhel5~]#mkdir -p /usr/local/mysql                 //安装mysql 
[root@ rhel5~]#mkdir -p /usr/local/mysql/data            //存放数据库
3.创建新的用户

[root@ rhel5~]groupadd mysql
[root@ rhel5~]useradd -r -g mysql mysql
4.安装mysql 

[root@ rhel5 mysql-5.5.10]#cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\
-DMYSQL_DATADIR=/usr/local/mysql/data\
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1
接下来 make && make install

5.设置

[root@ rhel5~]# cd /usr/local/mysql
[root@ rhel5 mysql]# chown -R root:mysql . //把当前目录中所有文件的所有者所有者设为root,所属组为mysql
[root@ rhel5 mysql]# chown -R mysql:mysql data
[root@ rhel5 mysql]# cp support-files/my-medium.cnf /etc/my.cnf //将mysql的启动服务添加到系统服务中

6.创建表

[root@ rhel5 mysql]# cd /usr/local/mysql
[root@ rhel5 mysql]# scripts/mysql_install_db --user=mysql
7.添加启动方式

[root@ rhel5 mysql]# cp support-files/mysql.server  /etc/init.d/mysql //将mysql的启动服务添加到系统服务中

8.然后再用#service mysql start 来启动mysql即可。

mysql一些基本操作

1.备份数据库

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema | 
| hello              | 
| mysql              | 
| performance_schema | 
| test               | 
+--------------------+
5 rows in set (0.00 sec)

mysql> use hello;
Database changed
mysql> show tables;
+-----------------+
| Tables_in_hello |
+-----------------+
| children        | 
+-----------------+
1 row in set (0.00 sec)


mysql> describe  children;
+---------+-------------+------+-----+---------+----------------+
| Field   | Type        | Null | Key | Default | Extra          |
+---------+-------------+------+-----+---------+----------------+
| childno | int(11)     | NO   | PRI | NULL    | auto_increment | 
| fname   | varchar(30) | YES  |     | NULL    |                | 
| age     | int(11)     | YES  |     | NULL    |                | 
+---------+-------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)

备份数据库

mysqldump [.......] --databases databasesname >name.sql
[luren@localhost ~]$ mysqldump -h 127.0.0.1 -u root -phello --databases hello >hello.sql

取回数据库

[luren@localhost ~]$ mysql -h 127.0.0.1 -u root -phello <hello.sql 

备份数据表

mysqldump [......] database tables >children.sql

[luren@localhost ~]$ mysqldump -h 127.0.0.1 -u root -phello hello children >children.sql

取回数据表

mysql  [......] database tables  <children.sql   

[luren@localhost ~]$ mysql -h 127.0.0.1 -u root -phello hello  <children.sql   

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值