Sie sind auf Seite 1von 6

https://dev.mysql.com/doc/refman/5.7/en/binary-installation.

html

General steps:

As root user:

# groupadd mysql

# useradd -r -g mysql -s /bin/false mysql

https://dev.mysql.com/downloads/mysql/

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

Decide where the mysql software will be located e.g /usr/local


cd /usr/local

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

You end up with /usr/local/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

tar –xzvf /usr/local/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

ln -s /usr/local/mysql-5.7.21-linux-glibc2.12-x86_64 mysql

cd mysql

Create a location to put the mysql-files (data files, Log files, backups etc)

Create the folders or directories

mkdir –p /usr/local/data

mkdir –p /usr/local/logs

mkdir –p /usr/local/backups

Make sure mysql user and mysql group owns the folders and files in them

chown -R mysql:mysql /usr/local/data

chown -R mysql:mysql /usr/local/logs

chown -R mysql:mysql /usr/local/backups

Modify the permissions

chmod 750 /usr/local/data


chmod 750 /usr/local/logs

chmod 750 /usr/local/backups

https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html

Make sure that the database directories and files are owned by the mysql login account so that the server
has read and write access to them when you run it later. To ensure this, start mysqld from the system
root account and include the --user

bin/mysqld --initialize-insecure --user=mysql

NB: It might be necessary to specify other options such as --basedir or --datadir if mysqld cannot
identify the correct locations for the installation directory or data directory.

bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/data

bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/data

Alternatively, put the relevant option settings in an option file and pass the name of that file to mysqld

In /etc/my.cnf

[mysqld]

basedir=/usr/local/mysql

datadir=/usr/local/data
Then invoke mysqld on a single line with the --defaults-file option first:

bin/mysqld --defaults-file=/etc/my.cnf --initialize-insecure --user=mysql

Start MySQL

For now let’s not generate ssl certificates, so skip step 11

bin/mysqld_safe --user=mysql &

The mysqld_safe will start mysqld server as the mysql user and the & will send the mysqld_safe
command to the background.

Check the error log for verification of a successful startup and then log in.

After connecting, assign a new root password:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

cp support-files/mysql.server /etc/init.d/mysql.server

Its best to call the script by the name you will use to call it with either
the service command or systemctl command.

Also older systems put it in /etc/rc.d./init.d

cp support-files/mysql.server /etc/init.d/mysqld

cp support-files/mysql.server /etc/rc.d./init.d/mysqld

Make sure MySQL server starts when the Linux server reboots:

Make sure it runs on run levels 3,4 and 5


chkconfig --add mysqld

the mysqld will be the name of the script needed to run or start MySQL
server. It the name was mysql instead of mysqld:

cp support-files/mysql.server /etc/init.d/mysql

chkconfig --add mysql

Verify the run levels at which MySQL Server will run or be on

chkconfig --list mysqld

or

chkconfig --list mysql

Make sure you can get to all the MySQL programs or executable binaries from
anywhere on the system you are logged into by adding the bin folder path to
the Linux OS system path.

The ln command makes a symbolic link to the installation directory. This


enables you to refer more easily to it as /usr/local/mysql. To avoid having
to type the full path name of client programs always when you are working
with MySQL, you can add the /usr/local/mysql/bin directory to your PATH
variable:

ln -s /usr/local/mysql-5.7.21-linux-glibc2.12-x86_64 mysql

export PATH=$PATH:/usr/local/mysql/bin

To make this permanent to the system to survive a linux reboot add the export
to the system profile and your bash_profile file.

First, let’s see your current $PATH’s value.

$ echo $PATH

In different shells this can be:

Bash shell -> ~/.bash_profile, ~/.bashrc or profile

Korn Shell -> ~/.kshrc or .profile

Z shell -> ~/.zshrc or .zprofile

echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> /etc/profile


echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile

The changes will not take effect until you log out of the terminal and re-log
back in.

Force the system to re-read the profile files while logged in:

source ~/.bash_profile

Das könnte Ihnen auch gefallen