下载mysql:

选择一个mysql的版本,之后一定要看好,下glibc的。如:mysql-5.0.90-linux-i686-glibc23.tar.gz

本例中下载到了/media目录下,这个不是好习惯...

▲安装mysql:

下面是linux命令

:$ sudo groupadd mysql

:$ sudo useradd -g mysql mysql

:$ cd /usr/local

:$ tar zvxf /media/mysql-5.0.90-linux-i686-glibc23.tar.gz

:$ mv mysql-5.0.90-linux-i686-glibc23 mysql

:$ cd mysql

:$ sudo chown -R mysql .

:$ sudo chgrp -R mysql .

:$ scripts/mysql_install_db --user=mysql  --basedir=/usr/local/mysql

:& cd ..

:$ sudo chown -R root mysql .

:$ cd mysql

:$ sudo chown -R mysql data

:$ bin/mysqld_safe --basedir=/usr/local/mysql --user=mysql &

至此,mysql安装成功。

因为在运行状态,我没有ctrl-c,只好再开一个ssh窗口...

▲为mysql的root用户添加密码

下面是linux命令

cd /usr/local/mysql/bin ./mysql -u root

进入mysql后:

mysql>  GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY"chang";

其实是设置了root的localhost的密码为chang

显示执行成功,然后exit退出mysql。

之后,再次登录mysql,这次要用密码了:

cd /usr/local/mysql/bin./mysql -u root -p

输入密码chang之后,可以正常登录,如下:

Welcome to the MySQL monitor.  Commands end with ; or /g.

Your MySQL connection id is 1

Server version: 5.0.90 MySQL Community Server (GPL)

Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.

查看一下用户信息:

mysql> select user,host,password from mysql.user;

结果如下:

+------+-----------+----------+

| user | host      | password |

+------+-----------+----------+

| root | localhost |  *F05D019BA3BEC01CA9FBD4141E4EA57A28EF3EDF  |   ← (root密码为chang)

| root | linux        |            |   ← (root密码为空)

| root | 127.0.0.1 |           |   ← (root密码为空)

|        | localhost  |           |

+------+-----------+----------+

分别更改它们的密码:

mysql>setpasswordforroot@localhost=password('chang');

mysql>setpasswordforroot@linux=password('chang');

mysql>setpasswordforroot@127.0.0.1=password('chang');

再次查看用户信息会发现已经更改过来。

然后退出mysql。

▲把mysql做成服务

sudo cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

启动mysql服务

sudo /etc/init.d/mysql start

这时候就可以重启机器试试了

重启后再登陆mysql,发现可以登陆。服务制作成功!

▲配置mysql

vi /etc/my.cnf

(注释:如果没有自动生成my.cnf文件,那么:安装完的mysql包下有个support-files文件夹,其中有my-huge.cnf等,将my-huge copy一份,改名为my.cnf,将其适当地修改(当然是根据你的数据库配置)然后copy至/etc/my.cnf)

打开my.cnf后

找到[client] 添加:

default-character-set = utf8      # 默认字符集为utf8

找到[mysqld] 添加:

default-character-set = utf8       #默认字符集为utf8

init_connect = 'SET NAMES utf8' #设定连接mysql数据库时使用utf8编码,以让mysql数据库为utf8运行

修改好后,重新启动即可.

我这里是重启了mysql的服务:

sudo /etc/init.d/mysql restart

(有一次找不到sock,这样重启两次服务之后居然可以了!!!汗。)

之后进入mysql,查一下是否更改了字符集:

cd /usr/local/mysql/bin./mysql -u root -p

mysql> show variables like'character%';

出现下面的画面:

+--------------------------+----------------------------------------+

| Variable_name            | Value                                  |

+--------------------------+----------------------------------------+

| character_set_client     | utf8                                   |

| character_set_connection | utf8                                   |

| character_set_database   | utf8                                   |

| character_set_filesystem | binary                                 |

| character_set_results    | utf8                                   |

| character_set_server     | utf8                                   |

| character_set_system     | utf8                                   |

| character_sets_dir       | /usr/local/mysql/share/mysql/charsets/ |

+--------------------------+----------------------------------------+

好,数据库语言完毕。

▲打开mysql的远程访问mysql默认是不允许远程访问的。

用密码登陆mysql,可以正常登陆,但是换台机器用工具连,就报错:

ERROR 1130: Host 192.168.1.6 is not allowed to connect to this MySQL server

方法: 改表法。mysql默认是不允许远程访问的,只能在localhost访问。这个时候只要在localhost的那台电脑,登入mysql后,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改成”%”

mysql -u root -p

Enter password: chang

mysql>use mysql;

mysql>update user set host = '%' where user = 'root';  //可能会报错

mysql>flush privileges;

mysql>select host,user from user where user='root';

执行完上面的,就可以远程连接了!

注释:

update user set host = '%' where user = 'root'; //这个命令执行错误时,可能会报错:

ERROR 1062 (23000): Duplicate entry '%-root' for key 1;

解决方法:

1,不用管它。呵呵。

2,改成这样执行

update user set host='%' where user='root' and host='localhost';

也就是把localhost改成了所有主机。

---------------------------------------------------

之后运行app程序,报错:

ImportError: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory

解决办法是把/usr/local/mysql/lib下的

libmysqlclient_r.so.15

拷贝到/usr/lib解决。

至此,mysql安装配置完毕!

================= 我是华丽的分割线 ========================

----------------------------------------------------

■附注:

附注1: 重启和关闭mysql服务

重启mysql服务

:$ sudo /etc/init.d/mysql restart

关闭mysql服务

:$ sudo /etc/init.d/mysql stop

----------------------------------------------------

附注2: 非服务状态下,启动和停止mysql

启动mysql

代码:

:& cd /usr/local/mysql

:& bin/mysqld_safe --basedir=/usr/local/mysql --user=mysql &

停止mysql

代码:

:& cd /usr/local/mysql

:$ bin/mysqladmin -uroot -ppassw0rd shutdown

----------------------------------------------------

附注3: mysql命令行中文显示?号

mysql> set names utf8;

---------------------------------------------------

附注4: mysql的数据库存放路径

/var/lib/mysql

---------------------------------------------------

附注5: 从mysql中导出和导入数据

mysqldump 数据库名 > 文件名 #导出数据库

mysqladmin create 数据库名 #建立数据库

mysql 数据库名 < 文件名 #导入数据库

---------------------------------------------------

附注6: 修改mysql的root口令

sudo mysqladmin -u root -p password '你的新密码'

或者:括号里是新密码

use mysql;

update user set Password=password('chang') where User='root';

flush privileges;

---------------------------------------------------

附注7: 忘了mysql的root口令怎么办

sudo /etc/init.d/mysql stop

sudo mysqld_safe --skip-grant-tables &

sudo mysqladmin -u user password 'newpassword

sudo mysqladmin flush-privileges

---------------------------------------------------

附注8: 输入要登录的mysql主机

./mysql -u root -h 127.0.0.1 -p

执行安全设置

#bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current

password for the root user. If you've just installed MySQL, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none):

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation.

Set root password? [Y/n] Y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account created for

them. This is intended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] Y

... Success!

Normally, root should only be allowed to connect from 'localhost'. This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y

... Success!

By default, MySQL comes with a database named 'test' that anyone can

access. This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n]

- Dropping test database...

... Success!

- Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] Y

... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MySQL

installation should now be secure.

Thanks for using MySQL!

mysql glibc包很大_linux 安装 mysql 的 glibc 包相关推荐

  1. mysql sql.gz 解压_linux 安装mysql数据库——tar.gz包解压安装法

    mysql数据库有多种安装方式,本文只介绍在Linux服务器上的tar.gz包解压安装法, 先通过mysql官网或者网络资源下载 mysql-5.7.3-m13-linux-glibc2.5-x86_ ...

  2. yum安装mysql驱动_centos7下使用yum安装mysql

    标签: CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1. 下载mysql的repo源 $ wget http://repo.mysql ...

  3. mysql repo_centos7下使用wget命令安装mysql

    首先安装wget命令: 1. 下载mysql的repo源 $  wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm ...

  4. ubuntu安装mysql远程_Ubuntu18.04下远程安装MySQL

    1.安装全新ubuntu-18.04.4-live-server-amd64版本,安装过程中勾选OpenSSH选项,然后通过PuTTY连接Ubuntu服务器: 2.安装ftp软件,vsftpd, su ...

  5. centos安装MySQL到指定盘_Centos下安装mysql 和挂载硬盘

    一,CentOS下安装Mysql 6.5 1.检测系统是否自带安装mysql # yum list installed | grep mysql 2.删除已经安装的Mysql # yum -y rem ...

  6. mysql 5.6 for centos_编译安装MySQL 5.6.16 for CentOS 6.4

    #--------------------------------------# # create by xk # by 2014-3-27 # 运维社区 #--------------------- ...

  7. mysql数据库开启远程连接_安装MySQL数据库并开启远程访问

    一.安装MySQL数据库 MySQL安装在系统盘下(C:\Program Files),方便系统备份. 1.双击安装程序,勾选"I accept the license terms" ...

  8. 抓包概念大比较:数据报、数据包、分组

    抓包概念大比较:数据报.数据包.分组 数据报.数据包和分组是常见的三个概念.他们是否一样?如果不一样,他们差别在哪里?下面依次说明这三个词.大学霸IT达人 1.数据报:当应用程序按照协议格式构建好要发 ...

  9. MySQL--入门篇:MySQL入门必会知识 Windows安装MySQL的zip包 一步一步带你图解安装MySQL过程 详细图解MySQL语句

    阅读目录 数据和数据库 MySQL介绍 MySQL的详细安装教程 Windows版本:MySQLl的安装.启动和基础配置 下载 配置 环境变量 安装 和 启动MySQL服务端 MySQL的卸载 MyS ...

最新文章

  1. 用python操作mysql数据库(之“更新”操作)
  2. javascript + css 利用div的scroll属性让TAB动感十足
  3. iOS 9 学习系列:UIStack View
  4. 分享超酷的添加图片悬浮特效jQuery插件 - Adipoli
  5. 关于海量数据查找排序问题
  6. 欲瘦其包,必先探清其底细
  7. Java Vector Capacity()方法与示例
  8. Vue还有这种骚操作?浅析几个新手常常忽略的API
  9. WatiN-Html元素及元素属性识别-扩展
  10. 黑客成长之路-01.新手篇-设置路由器
  11. shell 函数和数组
  12. Arturia V Collection 8 for mac - Arturia系列合成器插件大合集
  13. html css js介绍ppt,HTML+CSS+JS-入门基础.ppt
  14. 迅为IMX6ULL开发板点亮第一个led灯之led子系统的使用
  15. 智慧化工园区解决方案
  16. 使用SecureCRT连接虚拟机中Linux系统 和 虚拟机网络配置
  17. 如何快速入门成为一名数据分析师
  18. 优麒麟 19.04 即将发布,华为、阿里云、重大、360四大境像站鼎力支持!
  19. Lenovo启天M437 黑苹果efi引导文件
  20. 四分位数的应用——基于收入实例的箱体图与离群值规则

热门文章

  1. 浅论园子的人对广告的认识
  2. 微信小程序创建一个新项目
  3. 5 . 2 查 询 优 化 器
  4. 【unity3d study ---- 麦子学院】---------- unity3d常用组件及分析 ---------- Animator动画状态机...
  5. 【转载】oracle normal、sys、system、sysdba、sysoperdba的区别
  6. 剑指offer(C++)-JZ8:二叉树的下一个结点(数据结构-树)
  7. Windows下用CMake编译JsonCpp及配置(适合新手)
  8. 华为机试HJ10:字符个数统计
  9. linux用户limit修改,linux – 使用cgroups作为用户设置用户创建的systemd范围的MemoryLimit...
  10. 2021年你想转行吗?写给迷茫的你!