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

本文详细介绍了如何在本地系统上安装并配置MySQL数据库,包括创建用户组和用户,设置安装目录权限,初始化数据库,配置用户,设置环境变量,启动MySQL服务,并为root账户设置密码。此外,还提供了如何查看数据库、断开连接以及进行安全启动的步骤。最后,文章指导了如何将MySQL设置为开机自启动。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 进程号

一、综合实战—使用极轴追踪方式绘制信号灯 实战目标:利用对象捕捉追踪和极轴追踪功能创建信号灯图形 技术要点:结合两种追踪方式实现精确绘图,适用于工程制图中需要精确定位的场景 1. 切换至AutoCAD 操作步骤: 启动AutoCAD 2016软件 打开随书光盘中的素材文件 确认工作空间为"草图与注释"模式 2. 绘图设置 1)草图设置对话框 打开方式:通过"工具→绘图设置"菜单命令 功能定位:该对话框包含捕捉、追踪等核心绘图辅助功能设置 2)对象捕捉设置 关键配置: 启用对象捕捉(F3快捷键) 启用对象捕捉追踪(F11快捷键) 勾选端点、中心、圆心、象限点等常用捕捉模式 追踪原理:命令执行时悬停光标可显示追踪矢量,再次悬停可停止追踪 3)极轴追踪设置 参数设置: 启用极轴追踪功能 设置角度增量为45度 确认后退出对话框 3. 绘制信号灯 1)绘制圆形 执行命令:"绘图→圆→圆心、半径"命令 绘制过程: 使用对象捕捉追踪定位矩形中心作为圆心 输入半径值30并按Enter确认 通过象限点捕捉确保圆形位置准确 2)绘制直线 操作要点: 选择"绘图→直线"命令 捕捉矩形上边中点作为起点 捕捉圆的上象限点作为终点 按Enter结束当前直线命令 重复技巧: 按Enter可重复最近使用的直线命令 通过圆心捕捉和极轴追踪绘制放射状直线 最终形成完整的信号灯指示图案 3)完成绘制 验证要点: 检查所有直线是否准确连接圆心和象限点 确认极轴追踪的45度增量是否体现 保存绘图文件(快捷键Ctrl+S)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值