Skip to content

Setup MySQL database

padre edited this page Oct 27, 2024 · 1 revision

ColdBits

How to Create a MySQL Database and Connect to It

Step 1: Create the Database

To create a MySQL database for use with ColdBits or any other plugin, follow these steps:

1.1 Log into MySQL as root

Open your terminal and enter the following command:

mysql -u root -p

You will be prompted to enter the root password for MySQL. After entering the password, you will be logged into the MySQL shell.

1.2 Create the coldbits database

Once you are in the MySQL shell, create a new database by running:

CREATE DATABASE coldbits;

1.3 Verify the database was created

To check if the database was created successfully, list all databases:

SHOW DATABASES;

You should see coldbits in the list.

1.4 Exit MySQL

Once you've confirmed the database is created, you can exit the MySQL shell:

EXIT;

Step 2: Set a Password for the Database

ColdBits (or other plugins) may not function properly if there’s no password set for the database.

2.1 Access MySQL with superuser privileges

In your terminal, run:

sudo mysql

This will open the MySQL shell as a superuser.

2.2 Set a password for the root user

To set a password for the root user, run the following command:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';

Make sure to replace 'your_password' with your actual password.

2.3 Apply the changes

After setting the password, apply the changes:

FLUSH PRIVILEGES;

2.4 Exit MySQL

Finally, exit the MySQL shell:

EXIT;

If you ever want to export your MySQL database:

mysqldump -u root -p coldbits > coldbits.sql

Now your MySQL database is ready, and you can use it with ColdBits or other plugins. Make sure to update your plugin configuration to point to the new database and use the password you've set.