在Fedora10上安装MySQL5.0.18,告捷!

本文涉及的产品
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
简介:

又一次安MySQL了,为什么又呢,因为前面成功那次算配置,即配置Fedora10自带的MySQL,这个还不算自己安装的,所以有必要再安装一次,以后还装也有可能,换操作系统,换MySql版本都可能这样做。

前几次安装失败的精力总算没白花,这会安装顺利多了。当然,这篇网文的帮助也是不小的:http://www.hackbase.com/tech/2011-10-28/65455.html

我安装的mysql-5.0.18.tar.gz可以从这里下载:http://pan.baidu.com/share/link?shareid=3134485043&uk=34256769

 

正文开始了,首先解压。

[root@Dawalixi hy]# tar xvzf mysql-5.0.18.tar.gz
...
mysql-5.0.18/server-tools/instance-manager/buffer.h
mysql-5.0.18/server-tools/instance-manager/buffer.cc
mysql-5.0.18/server-tools/instance-manager/parse.cc
mysql-5.0.18/server-tools/instance-manager/parse.h
mysql-5.0.18/server-tools/instance-manager/guardian.cc
mysql-5.0.18/server-tools/instance-manager/guardian.h
mysql-5.0.18/server-tools/instance-manager/parse_output.cc
mysql-5.0.18/server-tools/instance-manager/parse_output.h
mysql-5.0.18/server-tools/instance-manager/mysql_manager_error.h
mysql-5.0.18/server-tools/instance-manager/portability.h

看看解压完的目录
[root@Dawalixi hy]# ls
4.sh    Desktop    Download  mysql-5.0.18         Pictures  Templates
backup  Documents  Music     mysql-5.0.18.tar.gz  Public    Videos
[root@Dawalixi hy]#

进行设置,utf8一项很重要,因为这个数据库将来要容纳中文
[root@Dawalixi mysql-5.0.18]# ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charsets=all 
...
config.status: creating read/Makefile
config.status: creating rem/Makefile
config.status: creating row/Makefile
config.status: creating srv/Makefile
config.status: creating sync/Makefile
config.status: creating thr/Makefile
config.status: creating trx/Makefile
config.status: creating usr/Makefile
config.status: creating ib_config.h
config.status: ib_config.h is unchanged
config.status: executing depfiles commands

MySQL has a Web site at http://www.mysql.com/ which carries details on the
latest release, upcoming features, and other information to make your
work or play with MySQL more productive. There you can also find
information about mailing lists for MySQL discussion.

Remember to check the platform specific part of the reference manual for
hints about installing MySQL on your platform. Also have a look at the
files in the Docs directory.

Thank you for choosing MySQL!

开始编译
[root@Dawalixi mysql-5.0.18]# make
...
".deps/parse_output.Tpo"; exit 1; fi
/bin/sh ../../libtool --preserve-dup-deps --mode=link g++  -O3 -DDBUG_OFF    -fno-implicit-templates -fno-exceptions -fno-rtti  -rdynamic  -o mysqlmanager  command.o mysqlmanager.o manager.o log.o thread_registry.o listener.o protocol.o mysql_connection.o user_map.o messages.o commands.o instance.o instance_map.o instance_options.o buffer.o parse.o guardian.o parse_output.o liboptions.a libnet.a ../../vio/libvio.a ../../mysys/libmysys.a ../../strings/libmystrings.a ../../dbug/libdbug.a -lz -lpthread -lcrypt -lnsl -lm  -lpthread 
mkdir .libs
g++ -O3 -DDBUG_OFF -fno-implicit-templates -fno-exceptions -fno-rtti -rdynamic -o mysqlmanager command.o mysqlmanager.o manager.o log.o thread_registry.o listener.o protocol.o mysql_connection.o user_map.o messages.o commands.o instance.o instance_map.o instance_options.o buffer.o parse.o guardian.o parse_output.o  liboptions.a libnet.a ../../vio/libvio.a ../../mysys/libmysys.a ../../strings/libmystrings.a ../../dbug/libdbug.a -lz -lpthread -lcrypt -lnsl -lm -lpthread
make[3]: Leaving directory `/home/hy/mysql-5.0.18/server-tools/instance-manager'
make[3]: Entering directory `/home/hy/mysql-5.0.18/server-tools'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/home/hy/mysql-5.0.18/server-tools'
make[2]: Leaving directory `/home/hy/mysql-5.0.18/server-tools'
make[1]: Leaving directory `/home/hy/mysql-5.0.18'

安装了!
[root@Dawalixi mysql-5.0.18]# make install
...
make[2]: Leaving directory `/home/hy/mysql-5.0.18/support-files'
Making install in server-tools
make[2]: Entering directory `/home/hy/mysql-5.0.18/server-tools'
Making install in instance-manager
make[3]: Entering directory `/home/hy/mysql-5.0.18/server-tools/instance-manager'
make[4]: Entering directory `/home/hy/mysql-5.0.18/server-tools/instance-manager'
test -z "/usr/local/mysql/libexec" || mkdir -p -- . "/usr/local/mysql/libexec"
  /bin/sh ../../libtool --preserve-dup-deps --mode=install /usr/bin/install -c 'mysqlmanager' '/usr/local/mysql/libexec/mysqlmanager'
/usr/bin/install -c mysqlmanager /usr/local/mysql/libexec/mysqlmanager
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/home/hy/mysql-5.0.18/server-tools/instance-manager'
make[3]: Leaving directory `/home/hy/mysql-5.0.18/server-tools/instance-manager'
make[3]: Entering directory `/home/hy/mysql-5.0.18/server-tools'
make[4]: Entering directory `/home/hy/mysql-5.0.18/server-tools'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/home/hy/mysql-5.0.18/server-tools'
make[3]: Leaving directory `/home/hy/mysql-5.0.18/server-tools'
make[2]: Leaving directory `/home/hy/mysql-5.0.18/server-tools'
make[1]: Leaving directory `/home/hy/mysql-5.0.18'

增加mysql组和mysql用户
[root@Dawalixi mysql-5.0.18]# groupadd mysql
[root@Dawalixi mysql-5.0.18]# useradd -g mysql mysql

进入mysql的安装目录
[root@Dawalixi mysql-5.0.18]# cd /usr/local/mysql
[root@Dawalixi mysql]# ls
bin  include  info  lib  libexec  man  mysql-test  share  sql-bench

进入share目录是想得到my.cnf
[root@Dawalixi mysql]# cd share/
[root@Dawalixi share]# ls
mysql
[root@Dawalixi share]# cd mysql/
[root@Dawalixi mysql]# ls
binary-configure      italian                         ndb-config-2-node.ini
charsets              japanese                        norwegian
czech                 korean                          norwegian-ny
danish                mi_test_all                     polish
dutch                 mi_test_all.res                 portuguese
english               my-huge.cnf                     romanian
errmsg.txt            my-innodb-heavy-4G.cnf          russian
estonian              my-large.cnf                    serbian
fill_help_tables.sql  my-medium.cnf                   slovak
french                my-small.cnf                    spanish
german                mysql_fix_privilege_tables.sql  swedish
greek                 mysql-log-rotate                ukrainian
hungarian             mysql.server
[root@Dawalixi mysql]# vi my-medium.cnf #这一步就是看看,没改什么

拷贝mysql配置文件,2G以下内存选择my.medium.cnf,如果有原来的选择覆盖。
[root@Dawalixi mysql]# cp my-medium.cnf  /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y

下面进行数据表的安装
[root@Dawalixi mysql]# cd /usr/local/mysql/bin
[root@Dawalixi bin]# ls
comp_err           mysql_config                mysql_setpermission
innochecksum       mysql_convert_table_format  mysqlshow
msql2mysql         mysql_create_system_tables  mysql_tableinfo
myisamchk          mysqld_multi                mysqltest
myisam_ftdump      mysqld_safe                 mysqltestmanagerc
myisamlog          mysqldump                   mysqltestmanager-pwgen
myisampack         mysqldumpslow               mysql_tzinfo_to_sql
my_print_defaults  mysql_explain_log           mysql_waitpid
mysql              mysql_find_rows             mysql_zap
mysqlaccess        mysql_fix_extensions        perror
mysqladmin         mysql_fix_privilege_tables  replace
mysqlbinlog        mysqlhotcopy                resolveip
mysqlbug           mysqlimport                 resolve_stack_dump
mysqlcheck         mysql_install_db
mysql_client_test  mysql_secure_installation
[root@Dawalixi bin]# ./mysql_install_db --user=mysql

Installing all prepared tables
Fill help tables

To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h Dawalixi password 'new-password'
See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests

Please report any problems with the /usr/local/mysql/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at https://order.mysql.com

下面要把mysql添加到系统服务中
[root@Dawalixi bin]# pwd
/usr/local/mysql/bin
[root@Dawalixi bin]# cd /usr/local/mysql/share/mysql/
[root@Dawalixi mysql]# ls
binary-configure      italian                         ndb-config-2-node.ini
charsets              japanese                        norwegian
czech                 korean                          norwegian-ny
danish                mi_test_all                     polish
dutch                 mi_test_all.res                 portuguese
english               my-huge.cnf                     romanian
errmsg.txt            my-innodb-heavy-4G.cnf          russian
estonian              my-large.cnf                    serbian
fill_help_tables.sql  my-medium.cnf                   slovak
french                my-small.cnf                    spanish
german                mysql_fix_privilege_tables.sql  swedish
greek                 mysql-log-rotate                ukrainian
hungarian             mysql.server
[root@Dawalixi mysql]# cp mysql.server /etc/init.d/mysqld

现在可以使用系统服务了,不做这一步下一步设置密码也跑不起来。
[root@Dawalixi bin]# service mysqld start
Starting MySQL                                             [  OK  ]

下面给root用户设置密码
[root@Dawalixi mysql]# cd /usr/local/mysql/bin
[root@Dawalixi bin]# ./mysqladmin -u root password '123456'

进行数据库授权,需要提醒的是,只要授权一次,root的密码必须重设一次,切记。
[root@Dawalixi bin]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.0.18-log

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> grant all privileges on *.* to root@'%' identified by "root";
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> grant select,update,insert,delete,create on *.* to root@192.168.0.100 identified by "root";  #注意这里比上回增加了create,这是为了建表用的
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye

下面开始重设密码
[root@Dawalixi bin]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.0.18-log

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> use mysql
Database changed
mysql> update user set password=password('12345678') where user='root';
Query OK, 2 rows affected (0.00 sec)
Rows matched: 4  Changed: 2  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@Dawalixi bin]#

打开防火墙对3306端口的限制
[root@Dawalixi bin]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT  #这一行是我新加的
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

重启防火墙
[root@Dawalixi bin]# service iptables restart
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
[root@Dawalixi bin]#

此时端口应该对3306开放了
[root@Dawalixi bin]# netstat -tlnpu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      19227/mysqld        
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      1477/rpcbind        
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1836/sshd           
tcp        0      0 0.0.0.0:57846               0.0.0.0:*                   LISTEN      1490/rpc.statd      
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      1931/cupsd          
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1859/sendmail: acce 
tcp        0      0 :::111                      :::*                        LISTEN      1477/rpcbind        
tcp        0      0 :::22                       :::*                        LISTEN      1836/sshd           
udp        0      0 0.0.0.0:804                 0.0.0.0:*                               1477/rpcbind        
udp        0      0 0.0.0.0:45617               0.0.0.0:*                               1490/rpc.statd      
udp        0      0 0.0.0.0:818                 0.0.0.0:*                               1490/rpc.statd      
udp        0      0 0.0.0.0:68           

现在可以通过数据库客户端对MySql数据库进行连接了。

我想做的是增加一张表,然后加入两条带中文的记录。

下面是加表。

 

插入记录

查询成功

 

接下来从服务器上查看下客户端加入进来的数据
[root@Dawalixi bin]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 35
Server version: 5.0.18-log

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> use mysql;
Database changed
mysql> select * from testtb;
+--------------+----------+
| name         | password |
+--------------+----------+
     | 123      |
         | 456      |
+--------------+----------+
2 rows in set (0.00 sec)

mysql> quit
Bye
[root@Dawalixi bin]# 
很好,表和中文文字都加入进来了,说明之前对MySQL的设置是正确的。


《全文完》有问题烦请指出















本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/xiandedanteng/p/3305803.html,如需转载请自行联系原作者


相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
相关文章
|
6月前
|
关系型数据库 应用服务中间件 nginx
Docker一键安装中间件(RocketMq、Nginx、MySql、Minio、Jenkins、Redis)
本系列脚本提供RocketMQ、Nginx、MySQL、MinIO、Jenkins和Redis的Docker一键安装与配置方案,适用于快速部署微服务基础环境。
|
3月前
|
Ubuntu 关系型数据库 MySQL
MySQL源码编译安装
本文详细介绍了MySQL 8.0及8.4版本的源码编译安装全过程,涵盖用户创建、依赖安装、cmake配置、编译优化等步骤,并提供支持多Linux发行版的一键安装脚本,适用于定制化数据库部署需求。
438 4
MySQL源码编译安装
|
3月前
|
Ubuntu 关系型数据库 MySQL
MySQL二进制包安装
本文详细介绍了在多种Linux系统上通过二进制包安装MySQL 8.0和8.4版本的完整过程,涵盖用户创建、glibc版本匹配、程序解压、环境变量配置、初始化数据库及服务启动等步骤,并提供支持多发行版的一键安装脚本,助力高效部署MySQL环境。
420 4
MySQL二进制包安装
|
3月前
|
安全 关系型数据库 MySQL
MySQL包安装 -- SUSE系列(离线RPM包安装MySQL)
本文详细介绍在openSUSE系统上通过离线RPM包安装MySQL 8.0和8.4版本的完整步骤,包括下载地址、RPM包解压、GPG密钥导入、使用rpm或zypper命令安装及服务启动验证,涵盖初始密码获取与安全修改方法,适用于无网络环境下的MySQL部署。
448 3
MySQL包安装 -- SUSE系列(离线RPM包安装MySQL)
|
3月前
|
关系型数据库 MySQL Linux
MySQL包安装 -- SUSE系列(SUSE资源库安装MySQL)
本文介绍了在openSUSE系统上通过SUSE资源库安装MySQL 8.0和8.4版本的完整步骤,包括配置国内镜像源、安装MySQL服务、启动并验证运行状态,以及修改初始密码等操作,适用于希望在SUSE系列系统中快速部署MySQL的用户。
281 3
MySQL包安装 -- SUSE系列(SUSE资源库安装MySQL)
|
3月前
|
NoSQL 算法 Redis
【Docker】(3)学习Docker中 镜像与容器数据卷、映射关系!手把手带你安装 MySql主从同步 和 Redis三主三从集群!并且进行主从切换与扩容操作,还有分析 哈希分区 等知识点!
Union文件系统(UnionFS)是一种**分层、轻量级并且高性能的文件系统**,它支持对文件系统的修改作为一次提交来一层层的叠加,同时可以将不同目录挂载到同一个虚拟文件系统下(unite several directories into a single virtual filesystem) Union 文件系统是 Docker 镜像的基础。 镜像可以通过分层来进行继承,基于基础镜像(没有父镜像),可以制作各种具体的应用镜像。
573 5
|
4月前
|
安全 关系型数据库 MySQL
CentOS 7 yum 安装 MySQL教程
在CentOS 7上安装MySQL 8,其实流程很清晰。首先通过官方Yum仓库来安装服务,然后启动并设为开机自启。最重要的环节是首次安全设置:需要先从日志里找到临时密码来登录,再修改成你自己的密码,并为远程连接创建用户和授权。最后,也别忘了在服务器防火墙上放行3306端口,这样远程才能连上。
749 16
|
3月前
|
Ubuntu 关系型数据库 MySQL
MySQL包安装 -- Debian系列(离线DEB包安装MySQL)
本文详细介绍了在Ubuntu 24.04、22.04、20.04及Debian 12系统上,通过离线DEB包安装MySQL 8.0和8.4版本的完整步骤。涵盖下载地址、依赖处理、dpkg安装顺序、配置方法及服务启动验证,确保用户可顺利部署MySQL数据库。
1318 0
MySQL包安装 -- Debian系列(离线DEB包安装MySQL)
|
3月前
|
运维 Ubuntu 关系型数据库
MySQL包安装 -- Debian系列(Apt资源库安装MySQL)
本文介绍了在Debian系列系统(如Ubuntu、Debian 11/12)中通过APT仓库安装MySQL 8.0和8.4版本的完整步骤,涵盖添加官方源、配置国内镜像、安装服务及初始化设置,并验证运行状态,适用于各类Linux运维场景。
1089 0
MySQL包安装 -- Debian系列(Apt资源库安装MySQL)
|
3月前
|
Oracle 关系型数据库 MySQL
MySQL包安装 -- RHEL系列(离线RPM包安装MySQL)
本文详细介绍在Rocky、CentOS、AlmaLinux、openEuler等主流Linux系统上,通过离线RPM包安装MySQL 8.0和8.4版本的完整步骤,涵盖下载、依赖处理、rpm/yum安装、服务启动、密码设置等关键环节,适用于多种企业级环境部署需求。
887 0
MySQL包安装 -- RHEL系列(离线RPM包安装MySQL)