`
gaojingsong
  • 浏览: 1163864 次
  • 性别: 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
分享到:
评论

相关推荐

    linux下源码安装mysql数据库

    源码安装linux下的mysql数据库。

    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-java-5.1.37jar包和源码

    mysql-connector-java-5.1.37jar包和源码下载 最新mysqljar包

    mysql-5.0.41-linux-i686-glibc23

    mysql数据库linux下的源码,给自己也给别人一个方便

    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-8.0.33-winx64 绿色安装包,源自官网,添加了 bat 脚本,支持配置、数据初始化;支持一键启动

    很多情况下需要在客户端发布时发布 ...本文将阐述如何使用一个脚本启动并初始化 MySQL 8.0 的方法,涵盖数据库下载、脚本源码、测试及可能遇到的问题等。 https://blog.csdn.net/m0_47406832/article/details/130363959

    centos下mysql数据库源码安装教程

    centos6.8下mysql数据库源码安装详细教程.可直接复制运行

    mysql-8.0.16.tar.gz

    mysql8.0.16.tar.gz,mysql源码包,linux平台源码编译安装,下载mysql源码包,数据库mysql8.0

    Linux mysql-5.7.12

    MySQL (数据库服务器)是一款小型关联式数据库管理系统,MySQL (数据库服务器)的执行性能非常高,运行速度非常快,并非常容易使用,是一个非常捧的数据库。MySQL (数据库服务器)在世界上是最流行的数据库语言。...

    MySQL安全配置详解

    MySQL 可以在 redhat 环境下进行 RPM 安装和 debian 下 apt 安装,但是最新的包一般都是源码的形式,因此这里选择源码编译安装的方式。安装过程中需要注意以下几点: * 登陆官方网站 http://www.mysql.com,下载...

    linux 6.5 mysql数据库

    linux启动mysql ...MySQL 软件采用了双授权政策,分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,一般中小型和大型网站的开发都选择 MySQL 作为网站数据库。

    linux下安装mysql数据库5.6源码安装,修改登录用户密码

    本篇内容主要给大家讲解一下如何在linux下安装MYSQL数据库,并以安装MYSQL5.6版本为例子教给大家进行登录用户名和密码的修改等操作。 源码下载地址http://dev.mysql.com/downloads/mysql/5.6.html#downloads tar.gz...

    Linux MySQL(含集群)安装步骤,自己整理,超详细

    在 Linux 环境下,安装 MySQL 有三种方式:二进制软件包安装、RPM 包安装和通过对源码进行编译安装。每种方式都有其优缺点,二进制软件包安装是官方推荐的安装方式,适合初学者学习使用,安装简单,可以安装到任何...

    mysql-5.0.22-win32

    MySQL 软件采用了双授权政策(本词条"授权政策"),它分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,一般中小型网站的开发都选择 MySQL 作为网站数据库。由于其社区版的性能...

    linux64位mysql数据库安装包

    这个是mysql源码安装包,适用于linux 64位系统,自己安装过并搭建,亲测可用,适用于开发、生产使用

    linux下mysql数据库的操作的方法

    ①.Mysql数据库的安装: 数据库的安装分为源码安装和rpm安装。 当然对于老手来说需要进行一些自定义的配置,那么当然源码安装的灵活性要高一些。 但是这种安装方式需要管理员自己处理好于系统的依赖关系。 而rpm安装...

    Linux下卸载MySQL数据库

    如何在Linux下卸载MySQL数据库呢? 下面总结、整理了一下Linux平台下卸载MySQL的方法。 MySQL的安装主要有三种方式:二进制包安装(Using Generic Binaries)、RPM包安装、源码安装。对应不同的安装方式,卸载的步骤...

    mysql-essential-5.0.91-win32[1].msi

    MySQL 软件采用了双授权政策(本词条"授权政策"),它分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,一般中小型网站的开发都选择 MySQL 作为网站数据库。由于其社区版的性能...

    在Linux下编译安装MySQL并通过C语言操作MySQL数据库.pdf

    在Linux下编译安装MySQL并,通过C语言操作MySQL数据库,有具体的方法,源码等等,可以下的学习学习了

    Linux Web开发与数据库服务器环境搭建(设置)

    Linux是个一个性能优异,...3.基于源码编译的MySql数据库安装 4.Oracle数据库的安装(包括服务器端与客户端的安装) 5.Apache服务器的安装与配置(主要用来支持运行PHP程序) 6.PHP环境安装和配置 7.Flex开发环境搭建

Global site tag (gtag.js) - Google Analytics