Iată un tutorial pas cu pas despre cum să creezi o bază de date MySQL folosind MySQL® Database Wizard în cPanel. Acest instrument simplifică procesul de creare a unei baze de date, unui utilizator MySQL și atribuirii de permisiuni.
Cum să creezi o bază de date cu MySQL® Database Wizard în cPanel
1. Autentifică-te în cPanel
- Deschide browserul și accesează cPanel la adresa:
http://yourdomain.com/cpanel
- Înlocuiește
yourdomain.com
cu numele domeniului tău. - Introdu numele de utilizator și parola pentru contul cPanel.
- Înlocuiește
2. Accesează MySQL® Database Wizard
- După ce te-ai autentificat, derulează pagina în jos până găsești secțiunea Databases (Baze de date).
- Click pe opțiunea MySQL® Database Wizard.
3. Crearea bazei de date
- În primul pas al MySQL® Database Wizard, trebuie să creezi baza de date:
- În câmpul de text, introdu numele bazei de date. Prefixul bazei de date va fi setat automat (de exemplu,
username_databasename
). - Exemplu: Dacă introduci
mydb
în câmpul de text, numele complet al bazei de date va fi ceva de genulusername_mydb
.
- În câmpul de text, introdu numele bazei de date. Prefixul bazei de date va fi setat automat (de exemplu,
- După ce ai introdus numele bazei de date, apasă pe Next Step (Pasul următor).
4. Crearea unui utilizator MySQL
-
În pasul următor, trebuie să creezi un utilizator MySQL care va avea acces la baza de date.
- În câmpul Username, introdu numele utilizatorului MySQL. Prefixul utilizatorului va fi setat automat la fel ca pentru baza de date (de exemplu,
username_mysqluser
). - Exemplu: Dacă introduci
user
ca nume, utilizatorul complet va fi ceva de genulusername_user
.
- În câmpul Username, introdu numele utilizatorului MySQL. Prefixul utilizatorului va fi setat automat la fel ca pentru baza de date (de exemplu,
-
În câmpul Password și Password (Again), introdu și confirmă o parolă puternică pentru acest utilizator.
- Este recomandat să folosești Password Generator pentru a crea o parolă sigură și complexă.
-
După ce ai completat aceste câmpuri, apasă pe Create User (Creează utilizator).
5. Atribuirea permisiunilor utilizatorului MySQL
-
În pasul final, trebuie să specifici ce permisiuni va avea utilizatorul asupra bazei de date create.
- Dacă dorești ca utilizatorul să aibă acces complet la baza de date, bifează opțiunea All Privileges (Toate privilegiile).
-
Dacă dorești să atribui permisiuni specifice (citire, scriere, modificare etc.), poți selecta manual casetele pentru fiecare permisiune în parte.
-
După ce ai selectat permisiunile dorite, apasă pe Next Step pentru a finaliza configurarea.
6. Confirmare și finalizare
- După ce ai terminat toți pașii, vei primi un mesaj de confirmare că baza de date și utilizatorul MySQL au fost create cu succes.
- Acum poți folosi această bază de date și utilizatorul MySQL în aplicațiile sau scripturile tale.
7. Conectarea la baza de date MySQL
Pentru a utiliza această bază de date în scripturi sau aplicații, ai nevoie de următoarele informații:
- Numele bazei de date:
username_mydb
- Numele utilizatorului MySQL:
username_user
- Parola utilizatorului MySQL: (cea pe care ai setat-o în pasul 4)
- Host:
localhost
(în majoritatea cazurilor, pentru conexiuni locale)
Exemplu de conectare PHP:
$servername = "localhost";
$username = "username_user";
$password = "parola_ta";
$dbname = "username_mydb";
// Crearea conexiunii
$conn = new mysqli($servername, $username, $password, $dbname);
// Verificarea conexiunii
if ($conn->connect_error) {
die("Conexiune eșuată: " . $conn->connect_error);
}
echo "Conexiunea a fost realizată cu succes!";
Sfaturi suplimentare:
- Securitate: Asigură-te că parola utilizatorului MySQL este puternică și nu folosi nume de baze de date sau utilizatori ușor de ghicit.
- Managementul bazei de date: Poți gestiona ulterior baza de date și utilizatorii din secțiunea MySQL Databases din cPanel.
Prin acești pași, ai creat cu succes o bază de date MySQL folosind MySQL® Database Wizard din cPanel. Acum poți folosi baza de date pentru site-ul tău sau alte aplicații web.