`
gaojingsong
  • 浏览: 1182500 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

linux中mysql源码安装---操作配置数据库

阅读更多

1、安装默认的数据库
添加MySQL用户和用户组
[root@node1 ~]# groupadd mysql
[root@node1 ~]# useradd -g mysql mysql
进入安装目录,将程序二进制的所有权改为root,数据目录的说有权改为mysql用户,更新授权表
[root@node1 mysql-5.5.22]# cd /usr/local/mysql/
[root@node1 mysql]# chown -R root .
[root@node1 mysql]# chown -R mysql .
[root@node1 mysql]# chgrp -R mysql .
[root@node1 mysql]# scripts/mysql_install_db --user=mysql
2016-01-08 12:13:03 3745 [Note] Binlog end
2016-01-08 12:13:03 3745 [Note] InnoDB: FTS optimize thread exiting.
2016-01-08 12:13:03 3745 [Note] InnoDB: Starting shutdown...
2016-01-08 12:13:05 3745 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

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:

  ./bin/mysqladmin -u root password 'new-password'
  ./bin/mysqladmin -u root -h node1 password 'new-password'

Alternatively you can run:

  ./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

安全启动MySQL(默认密码为空)
[root@localhost mysql]# ./bin/mysqld_safe --user=mysql&
source /etc/profile
报错:(有可能卡住,动弹不了)
120908 00:16:25 mysqld_safe Logging to '/usr/local/mysql/data/node1.err'.
120908 00:16:26 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
解决方法:
[root@node1 ~]# cd /usr/local/mysql/data
[root@node1 data]# ls
auto.cnf  ib_logfile0  mysql      node1.pid           test
ibdata1   ib_logfile1  node1.err  performance_schema
[root@node1 data]# chgrp -R mysql node1.err
[root@node1 data]# ls -l
total 110736
-rw-rw---- 1 mysql mysql       56 Jan  8 12:15 auto.cnf
-rw-rw---- 1 mysql mysql 12582912 Jan  8 12:15 ibdata1
-rw-rw---- 1 mysql mysql 50331648 Jan  8 12:15 ib_logfile0
-rw-rw---- 1 mysql mysql 50331648 Jan  8 12:12 ib_logfile1
drwx------ 2 mysql mysql     4096 Jan  8 12:13 mysql
-rw-r----- 1 mysql mysql     2055 Jan  8 12:16 node1.err
-rw-rw---- 1 mysql mysql        5 Jan  8 12:15 node1.pid
drwx------ 2 mysql mysql     4096 Jan  8 12:13 performance_schema
drwxr-xr-x 2 mysql mysql     4096 Jan  7 20:42 test
 
2、配置用户,环境变量
MySQL启动成功后,root默认没有密码,我们需要设置root密码。
设置之前,我们需要先设置PATH,要不不能直接调用mysql
修改bash_profile文件,在文件末尾添加
[root@node1 ~]# vi .bash_profile
复制代码代码如下:
PATH=/usr/local/mysql/bin:$PATH
export PATH
关闭文件,运行下面的命令,让配置立即生效
复制代码代码如下:
[root@node1 root]# source .bash_profile

连接本机MySQL
[root@node1 mysql]#mysql –u root –p
提示输入password,默认为空,按Enter即可
[root@node1 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.28 Source distribution
Copyright (c) 2000, 2015, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.59 sec)

断开连接
mysql>exit;
为root账户设置密码
[root@node1 mysql]# mysqladmin -u root password 123456

设置选项文件,将配置文件拷贝到/etc下
[root@node1 mysql]# cp support-files/my-medium.cnf /etc/mysql.cnf
设置开机自启动
[root@node1 mysql]# cp support-files/mysql.server /etc/init.d/mysql
[root@node1 mysql]# chmod +x /etc/init.d/mysql
[root@node1 mysql]# chkconfig mysql on
 
3.安装设置完毕,之后使用只需启动-连接-断开-关闭,命令如下:
通过服务来启动和关闭Mysql
[root@node1 mysql]# service mysql start
Starting MySQL.. [确定]
[root@CentOS mysql]# service mysql stop
Shutting down MySQL. [确定]
4.其它:
查看进程命令 ps –ef|grep mysqld
kill进程命令 kill –9 进程号

0
0
分享到:
评论

相关推荐

    mysql for Linux (mysql-standard-4.1.22-pc-linux-gnu-i686.tar.gz )

    MySQL是世界上最受欢迎的开源数据库系统之一,尤其在Linux操作系统中广泛应用。`mysql-standard-4.1.22-pc-linux-gnu-i686.tar.gz` 是一个针对Linux平台的MySQL服务器版本的压缩包,适用于Intel x86架构。这个特定的...

    mysql-5.7.18源码和connector C++源码在Linux在编译安装

    3. **配置编译**:进入MySQL源码目录,使用`cmake`进行配置。例如: ``` mkdir build cd build cmake .. ``` 这里`..`代表上一级目录,即MySQL源码目录。你可以根据需求添加或修改配置选项,例如设置安装路径...

    linux下源码安装mysql数据库

    通过以上步骤,您已经成功地在Linux环境下完成了MySQL数据库的源码安装与配置。在整个过程中,不仅学习到了如何进行基础的目录与用户管理,还掌握了编译安装MySQL的全过程,这对于深入理解Linux下的软件部署流程有着...

    mysql-connector-java-5.1.37jar包和源码

    1. 添加依赖:在Java项目中,你需要将`mysql-connector-java-5.1.37.jar`添加到项目的类路径中,这可以通过IDE的配置或在构建脚本(如Maven的pom.xml或Gradle的build.gradle)中指定依赖来实现。 2. 建立连接:使用...

    mysql-5.0.41-linux-i686-glibc23

    这个名为“mysql-5.0.41-linux-i686-glibc23”的压缩包文件包含的是MySQL 5.0.41版本针对Linux操作系统的源代码,特别适配于i686架构和glibc23库。让我们深入探讨一下这个版本的MySQL以及它在Linux环境中的部署和...

    mysql-5.7.44-linux-glibc2.12-x86-64.tar.gz

    在Linux环境下,MySQL通常以源码形式安装,以便更好地适应系统环境。本文将深入探讨MySQL 5.7.44在Linux(glibc2.12)上的安装和使用。 1. **MySQL 5.7.44 特性** - **InnoDB存储引擎优化**:在5.7版本中,InnoDB...

    mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

    在Linux中安装MySQL 5.7.18的步骤如下: 1. **上传文件**:使用`xftp`或类似工具,将`mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz`上传到你的Linux服务器,例如 `/home/user/` 目录下。 2. **解压文件**:使用`tar...

    mysql-8.0.33-linux-glibc2.12-x86-64.tar.xz

    centos或linux系统中使用的源码安装包,亲测有效。 MySQL 8.0.33于2023年4月18日GA,这可能是包含新功能、新特性的8.0的最后一个版本,未来的MySQL版本将会在发行方式上发生重大改变。 MySQL 企业版审计功能使用...

    mysql-connector-c-6.0.2-linux-sles10-x86-64bit

    总之,MySQL Connector/C-6.0.2是MySQL数据库在Linux环境下开发的重要工具,它为C语言程序员提供了连接和操作MySQL数据库的能力,尤其对于SLES 10 64位系统,这个版本提供了特定优化,确保了更好的性能和稳定性。

    django,liunx下mysql数据库接口MySQL-python-1.2.3.tar.gz

    在本案例中,我们讨论的是MySQL-python-1.2.3版本的源码包,它是一个用于Python连接MySQL数据库的库。 首先,让我们了解Django框架。Django是一个基于MTV(Model-Template-View)设计模式的高级Web开发框架,它鼓励...

    mysql-connector-c-6.0.2-linux-rhel5-x86-32bit.tar

    *********shenkxiao的资源********* mysql-connector-c-6.0.2-linux-rhel5-x86-32bit.tar;用于连接32位red hat linux 5.X下的mysql数据库的小工具。 *********只为共享合适的资源********

    mysql-5.5.27 linux源码安装文件

    MySQL是世界上最受欢迎的开源关系型数据库管理系统之一,尤其在Linux操作系统上被广泛使用。本文将详细介绍如何在Linux环境下,通过源代码方式安装MySQL 5.5.27版本。 源码安装MySQL的优点在于,你可以完全控制编译...

    Linux系统安装-mysql-apache-php组建借鉴.pdf

    在本教程中,我们将探讨如何在Linux系统上安装MySQL、Apache和PHP,这三个组件是搭建LAMP(Linux、Apache、MySQL、PHP)服务器的基础。首先,我们从Linux系统的安装开始。 1. **Linux系统安装** - **系统分区**: ...

    mysql-connector-j-8.0.32的压缩包,直接下载到本地,解压后即可使用

    MySQL Connector/J 8.0.32 是MySQL数据库与Java应用程序之间的重要桥梁,它是一个实现了JDBC(Java Database Connectivity)接口的驱动程序,允许Java开发者在应用中与MySQL数据库进行交互。MySQL是世界上最受欢迎的...

    LINUX下MYSQL源码安装和简单使用.pdf

    以下是对标题和描述中涉及的MySQL源码安装和简单使用的详细步骤: 1. **源码安装的原因**: - Linux操作系统可能未内置MySQL数据库。 - 对于不支持官方RPM包的特殊架构(如国产龙芯的MIPS指令系统)。 2. **...

    linux下连接mysql配置.docx

    在Linux环境下,连接MySQL数据库通常涉及安装必要的软件包、配置ODBC(Open Database Connectivity)以及设置数据源名称(DSN)。以下将详细解释这个过程: 首先,你需要安装`unixODBC`,这是一个开源的ODBC管理器...

    linux系统下源码版mysql安装

    本文将详细介绍如何在Linux系统下不借助cmake进行MySQL源码安装的具体步骤及其相关知识点。 #### 准备工作 在开始安装前,请确保您的Linux系统已经安装了必要的编译工具和库文件。例如GCC、make等基础开发工具,...

    mysql源码(mysql-8.1.0.tar.gz)

    6. **复制与高可用性**:MySQL的主从复制功能在8.1.0版本中可能会有增强,源码中可以研究半同步复制、GTID(全局事务标识符)等技术,以提高数据一致性和系统可用性。 7. **安全特性**:MySQL 8.x版本引入了更多...

Global site tag (gtag.js) - Google Analytics