MySQL数据库

简介

​ Apache HTTP Server作为优秀的Web服务器软件,提供了面向用户的前端应用功能。而在实际

的企业网站平台中,为了提供更丰富.更强大的Web应用功能,往往还需要有后台数据库、网页编

程语言等多种角色的支持。

基础认识

​ MySQL是一个真正的多线程、多用户的SQL数据库服务,凭借其高性能.高可靠和易于使
用的特性,成为服务器领域中最受欢迎的开源数据库系统。在2008年以前,MSQL项目由MySaL
AB公司进行开发、发布和支持,之后历经Sun公司收购MySQL AB公司,Oracle公司收购Sun公司
的过程,目前MySOL项目由Oracle公司负责运营和维护。

需求描述
编译安装MySOL服务器,并添加为mysqld系统服务。

为MySOL数据库的root用户设置密码,删除用户名.密码为空的用户记录。

新建名为“bdan”的库,授权用户rundb从本机访问,具有所有操作权限。
以rundb用户登录,在bdqn库中创建stuinfo表,并录入数据,如表3-2所示。

一、源代码安装mysql

MySQL 5.×系列版本需要cmake 编译安装,所以先安装cmake包。

1、安装

​ [[email protected] ~]# yum -y install ncurses-devel cmake
MySQL数据库系统

2、取消挂载光盘 更换源代码Linux光盘

MySQL数据库系统

3、解压缩mysql安装

​ [[email protected] ~]# tar zxf /mnt/mysql-5.5.22.tar.gz -C /usr/src/

MySQL数据库系统

4、配置mysql

​ [[email protected] mysql-5.5.22]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql - DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc/

MySQL数据库系统

5、编译和安装

​ [[email protected] mysql-5.5.22]# make && make install

MySQL数据库系统

安装时间稍长,安心等待即可

6、生成主配置文件 和 服务控制文件

​ [[email protected] mysql-5.5.22]# cp support-files/my-medium.cnf /etc/my.cnf

MySQL数据库系统

​ [[email protected] mysql-5.5.22]# cp support-files/mysql.server /etc/init.d/mysqld

MySQL数据库系统

​ 添加执行权限

​ [[email protected] mysql-5.5.22]# chmod +x /etc/init.d/mysqld

7、优化mysql命令

​ [[email protected] mysql-5.5.22]# vim /etc/profile

​ [[email protected] mysql-5.5.22]# source /etc/profile

MySQL数据库系统

8、初始化mysql

​ [[email protected] ~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data

MySQL数据库系统

9、添加为系统服务 启动服务

​ [[email protected] ~]# chkconfig --add mysqld

​ [[email protected] ~]# chkconfig --level 35 mysqld on
​ [[email protected] ~]# systemctl start mysqld

MySQL数据库系统
MySQL数据库系统

二、使用mysql

1、设置用户密码

​ [[email protected] ~]# mysqladmin -uroot passworf

MySQL数据库系统

2、登录mysql

​ [[email protected] ~]# mysql -uroot [email protected]

MySQL数据库系统

3、删除用户名和密码为空的用户

​ mysql> DELETE from mysql.user where user="" and password="";

MySQL数据库系统

4、创建bdqn库

​ mysql> create database bdqn;

MySQL数据库系统

5、授权rundb用户从本机访问 具有所有权限

​ mysql> grant all on bdqn.* to ‘rundb’@‘localhost’ identified by ‘123’;

MySQL数据库系统

6、退出用rendb用户登录

​ mysql> exit

​ [[email protected] ~]# mysql -urundb -p123

MySQL数据库系统

7、在bdqn库中创建stuinfo表,并录入数据

​ mysql> create table bdqn.stuinfo (名字 char(5),性别 char(1),年龄 i
nt, 联系电话 char(11), 地址 char(100));

MySQL数据库系统

​ 录入数据

​ mysql> insert into bdqn.stuinfo (名字,性别,年龄,联系电话,地址) values (‘张三’,‘男’,14,‘17523160000’,‘某城某市某县’);

查看数据

MySQL数据库系统

相关文章:

  • 2021-07-03
  • 2021-11-20
  • 2021-07-10
  • 2021-08-30
  • 2021-11-13
  • 2021-11-04
  • 2021-08-05
猜你喜欢
  • 2021-11-17
  • 2021-09-04
  • 2021-08-30
  • 2021-08-30
相关资源
相似解决方案